Are there any ways to check whether a key exists with RedisTemplate?

Lily picture Lily · Aug 23, 2017 · Viewed 8.4k times · Source

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?

Answer

Mobility picture Mobility · Aug 23, 2017

Yes, you can use public Boolean hasKey(K key).

You can just search exists in redisTemplate javadoc