首页
学习
活动
专区
圈层
工具
发布
社区首页 >专栏 >redis setnx java setIfAbsent的使用

redis setnx java setIfAbsent的使用

作者头像
oktokeep
发布2024-10-09 09:56:44
发布2024-10-09 09:56:44
1980
举报
文章被收录于专栏:第三方工具第三方工具

redis setnx java setIfAbsent的使用 如果为空就set值,并返回1 如果存在(不为空)不进行操作,并返回0

test:0>set mykey "hello" OK test:0>get mykey hello test:0>set mykey "world" OK test:0>get mykey world test:0>setnx mykey2 "hello" 1 test:0>get mykey2 hello test:0>setnx mykey2 "world" 0 test:0>get mykey2 hello test:0>del mykey 1 test:0>get mykey NULL test:0>del mykey2 1 test:0>get mykey2 NULL

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2022-08-12,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档