Login
网站首页 > 文章中心 > 其它

Redis 原子操作INCR_java redis原子操作

作者:小编 更新时间:2023-08-06 10:55:37 浏览量:162人看过

The content below come from http://try.redis.io/?

There is something special about?INCR. Why do we provide such an operation if we can do it ourself with a bit of code? After all it is as simple as:

x = GET count
x = x + 1
SET count x

The problem is that doing the increment in this way will only work as long as there is a single client using the key. See what happens if two clients are accessing this key at the same time:

Client A reads?count?as 10.

Client B reads?count?as 10.

Client A increments 10 and sets?count?to 11.

Client B increments 10 and sets?count?to 11.

以上就是土嘎嘎小编为大家整理的Redis 原子操作INCR相关主题介绍,如果您觉得小编更新的文章只要能对粉丝们有用,就是我们最大的鼓励和动力,不要忘记讲本站分享给您身边的朋友哦!!

版权声明:倡导尊重与保护知识产权。未经许可,任何人不得复制、转载、或以其他方式使用本站《原创》内容,违者将追究其法律责任。本站文章内容,部分图片来源于网络,如有侵权,请联系我们修改或者删除处理。

编辑推荐

热门文章