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
- Weekly Trends
- Python Interview Questions and Answers: Comprehensive Guide
- Scala Exercises, Practice, Solution
- Kotlin Exercises practice with solution
- MongoDB Exercises, Practice, Solution
- SQL Exercises, Practice, Solution - JOINS
- Java Basic Programming Exercises
- SQL Subqueries
- Adventureworks Database Exercises
- C# Sharp Basic Exercises
- SQL COUNT() with distinct
- JavaScript String Exercises
- JavaScript HTML Form Validation
- Java Collection Exercises
- SQL COUNT() function
- SQL Inner Join