The Redis EXISTS command is used to check whether a given key exists.
Recommended manual: Redis command operation Chinese manual
redis EXISTS command The basic syntaxis as follows:
redis 127.0.0.1:6379> EXISTS KEY_NAME
Available version>= 1.0.0
Return value
If the key exists, return 1, otherwise return 0.
Example
redis 127.0.0.1:6379> EXISTS w3cschoolcc-new-key (integer) 0
Now we create a key named w3cschoolcc-new-key and assign a value, and then use the EXISTS command.
redis 127.0.0.1:6379> set w3cschoolcc-new-key newkey OK redis 127.0.0.1:6379> EXISTS w3cschoolcc-new-key (integer) 1 redis 127.0.0.1:6379>
Recommended related articles:
1. How many keys can a redis instance store
2. Redis determines whether the value exists
Related video recommendations:
1. Yan Shiba redis video tutorial
The above is the detailed content of redis determines whether key exists. For more information, please follow other related articles on the PHP Chinese website!