如何在Memcached中处理并发更新? [英] How are concurrent updates handled in Memcached?

查看:195
本文介绍了如何在Memcached中处理并发更新?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的理解是,Memcached是无锁的(在其默认配置),以便没有客户端可以阻止任何其他客户端的操作。如果是这种情况,那么Memcached如何处理两个或多个客户端同时尝试更新同一个对象?



Memcached如何处理对象的多个版本?只是取最后更新完成的那个,并从缓存中驱逐其他版本?数据库是否主动使在Memcached服务器上缓存的对象无效?

解决方案

Memcached只保存对象的最后一个版本。如果你得到,修改并且你不能保证put应用与get相同的值。如果需要同步,可以使用CAS操作(获取 cas )。


My understanding is that Memcached is lockless (in its default configuration), such that no client can impede any other client's operation. If that is the case, then how does Memcached handle two or more clients attempting to update the same object at the same time?

How does Memcached handle multiple versions of an object? Simply take the one whose update finished last and evict the other versions from the cache? Is the database actively invalidating objects cached on a Memcached server?

解决方案

Memcached hold only last version of object. If you get, modify and put you have no guarantee that the put applies to the same value as the get. You could use CAS operations (gets, cas) if you need to synchronize.

这篇关于如何在Memcached中处理并发更新?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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