Redis EXISTS
EXISTS Keys
The Redis EXISTS command is used to check whether key exists in redis or not.
Since Redis 3.0.3 it is possible to specify multiple keys instead of a single one. In such a case, it returns the total number of keys existing. Note that returning 1 or 0 for a single key is just a special case of the variadic usage, so the command is completely backward compatible.
If the same existing key is mentioned in the arguments multiple times, it will be counted multiple times.
Syntax:
EXISTS KEY_NAME
Available since
1.0.0.
Return Value
-
Integer value . Specifically
- 1, if the key exists.
- 0, if the key does not exist.
Return Value Type
Integer
Example: Redis EXISTS
First, create a key in redis and set some value in it and check for the existence of it.
127.0.0.1:6379> SET key "Good" OK 127.0.0.1:6379> EXISTS key (integer) 1 127.0.0.1:6379> EXISTS KEY (integer) 0
- New Content published on w3resource:
- HTML-CSS Practical: Exercises, Practice, Solution
- Java Regular Expression: Exercises, Practice, Solution
- Scala Programming Exercises, Practice, Solution
- Python Itertools exercises
- Python Numpy exercises
- Python GeoPy Package exercises
- Python Pandas exercises
- Python nltk exercises
- Python BeautifulSoup exercises
- Form Template
- Composer - PHP Package Manager
- PHPUnit - PHP Testing
- Laravel - PHP Framework
- Angular - JavaScript Framework
- Vue - JavaScript Framework
- Jest - JavaScript Testing Framework