Memcached – GET和SET操作是原子的吗? [英] Memcached – Are GET and SET operations atomic?

查看:181
本文介绍了Memcached – GET和SET操作是原子的吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这里是场景:一个简单的网站,它查询内存缓存.批处理作业每10-15分钟更新一次相同的缓存.通过这种模式,有什么地方可能出问题(例如缓存未命中)?

Here is the scenario: a simple website which queries a memcached cache. That same cache is updated by a batch job every 10-15 minutes. With that pattern is there anything that could go wrong (e.g. cache miss)?

我对所有可能发生的赛车状况感到担忧.例如,如果网站对缓存在memcached中的对象执行GET操作,而批处理作业覆盖了该对象,那么会发生什么呢?

I am concerned by all the possible racing condition that could happen. For example, if the website does a GET operation on an object cached in memcached while that same object is overridden by the batch job, what will happen?

推荐答案

我的最初直觉是,您应该能够从内存缓存中进行读/写操作,而没有副作用(除了由于竞争条件而导致数据过时的可能性) ).

My initial instinct was that you should be able to read/write from a memcached cache with no side effects (other than a possibility of stale data due to race conditions).

关于memcached的常见问题解答:

On memcached's FAQ:

内存缓存是原子的吗?除了您可能遇到的任何错误外,是的 命令在内部是原子的.同时发行多套 没有不良影响,除了最后一个是 棒.

Is memcached atomic? Aside from any bugs you may come across, yes all commands are internally atomic. Issuing multiple sets at the same time has no ill effect, aside from the last one in being the one that sticks.

在不了解您的具体情况的情况下,我将无法建议是否可能发生高速缓存未命中,但我的确归纳为高速缓存应该是用于寻找数据的第一层,而不是唯一层;在高速缓存后面,我仍然会有一个数据库或其他来源来处理您所有的高速缓存未命中.

Without knowing more about your specific situation, I would not be able to advise on whether or not a cache miss was possible, but I do make a generalization that the cache should be a first tier for seeking data and not the ONLY tier; I would still have a database or some other source behind the cache to handle all of your cache misses.

这篇关于Memcached – GET和SET操作是原子的吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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