Memcached是获取和放置方法是线程安全的 [英] Is Memcached get and put methods are thread safe

查看:190
本文介绍了Memcached是获取和放置方法是线程安全的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在多线程环境中,是否有机会在memcached中为键获取乱码值?使用Java客户端访问memcached服务器


使用Java客户端访问memcached服务器

>解决方案

没有。 Memcache将返回某人先前写的值,而不是一个乱码值。如果你得到/修改/放弃,你不能保证这个卖出价与获得的价值相同。如果您需要同步,请使用cas(比较和设置)操作。


Is there any chance of getting a garbled value for a key in memcached in multi thread environment?. If so how to avoid it with minimal time of synchronization?.

Using Java client to access memcached server

解决方案

No. Memcache will return a value that somebody wrote previously, and not a garbled value. If you get/modify/put you have no guarantee that the put applies to the same value as the get. Use the cas (compare and set) operation if you need to synchronize.

这篇关于Memcached是获取和放置方法是线程安全的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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