组织记忆快取金钥 [英] Organizing memcache keys

查看:75
本文介绍了组织记忆快取金钥的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正试图找到一种处理内存缓存密钥的好方法,以便以更加文明的方式向缓存层存储数据,从缓存层检索数据和从缓存层更新数据.

Im trying to find a good way to handle memcache keys for storing, retrieving and updating data to/from the cache layer in a more civilized way.

找到了这种模式,看起来不错,但是如何将其转变为PHP应用程序的功能部分?

Found this pattern, which looks great, but how do I turn it into a functional part of a PHP application?

身份地图模式: http://martinfowler.com/eaaCatalog/identityMap.html

谢谢!

更新:有人告诉我修改过的内存缓存(memcache-tag)显然可以完成很多工作,但是我无法在Windows开发盒上安装linux软件...

Update: I have been told about the modified memcache (memcache-tag) that apparently does do a lot of this, but I can't install linux software on my windows development box...

推荐答案

Memcache使用IS是一种身份映射模式.您检查缓存,然后命中数据库(或其他使用的数据库).您可以通过存储对象而不只是值来查找有关源的信息,但是这样做会带来性能上的损失.

Well, memcache use IS an identity map pattern. You check your cache, then you hit your database (or whatever else you're using). You can go about finding information about the source by storing objects instead of just values, but you'll take a performance hit for that.

您实际上无法询问缓存列表中包含的内容.要使失效无效,您必须保留所放入内容的列表并对其进行迭代,否则,您必须对可能符合关注模式的所有可能的密钥进行迭代.您指出的资源memcache-tag可以简化此过程,但似乎并未与memcache项目保持内联.

You effectively cannot ask the cache what it contains as a list. To mass invalidate, you'll have to keep a list of what you put in and iterate it, or you'll have to iterate every possible key that could fit the pattern of concern. The resource you point out, memcache-tag can simplify this, but it doesn't appear to be maintained inline with the memcache project.

因此,您现在的选择是迭代删除,或完全刷新所有已缓存的内容.因此,我提出一个设计上的考虑是您应该问的问题.为了给您一个有用的答案,我这样询问:为什么要这样做?

So your options now are iterative deletes, or totally flushing everything that is cached. Thus, I propose a design consideration is the question that you should be asking. In order to get a useful answer for you, I query thus: why do you want to do this?

这篇关于组织记忆快取金钥的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆