redisTemplate的setnx
时间: 2023-11-14 14:25:18 浏览: 75
RedisTemplate的setnx方法是用来设置一个key-value对,如果这个key不存在,则设置成功并返回true;如果这个key已经存在,则设置失败并返回false。无论设置成功还是失败,get出来的value都是最开始set进去的那个value。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [RedisTemplate-JDBCTemplate.zip](https://download.csdn.net/download/drug1910951117/12635495)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
- *2* *3* [redistemplate实现 setnx分布式锁](https://blog.csdn.net/weixin_43850799/article/details/105355677)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文