Are there any ways to check whether a key exists with RedisTemplate?
or in other words, are there any equivalent of Redis exists
command in RedisTemplate API?
Asked
Active
Viewed 1.6k times
14

Lily
- 355
- 1
- 3
- 11
1 Answers
22
Yes, you can use public Boolean hasKey(K key)
.
You can just search exists in redisTemplate javadoc

Mobility
- 3,117
- 18
- 31
-
how about `get(key) == null`? – Lei Yang Aug 02 '23 at 08:43