w3resource

Redis Keys: TYPE

Redis TYPE Cammand

Redis TYPE command is used to get the data type of value stored in the key.

Here are some common uses and scenarios for the "TYPE" command:

  • Data Inspection: Identify the type of data stored at a specific key.
  • Conditional Operations: Execute commands based on the type of data stored.
  • Debugging: Verify data type consistency during development and troubleshooting.
  • Programmatic Logic: Implement conditional logic based on data type results.

Syntax:

TYPE KEY_NAME 

Available since

1.0.0.

Return Value

String reply, data type of value stored in the key or none

Return Value Type

Integer

Example: Redis TYPE

First, create some keys in redis and set some values in it.

127.0.0.1:6379> SET STR "JavaScript"
OK
127.0.0.1:6379> TYPE STR
string
127.0.0.1:6379> lpush list JAVA
(integer) 1
127.0.0.1:6379> TYPE list
list
127.0.0.1:6379> SADD set Python
(integer) 1
127.0.0.1:6379> TYPE set
set
127.0.0.1:6379> HSET hash 0 MySQL
(integer) 1
127.0.0.1:6379> TYPE hash
hash

Now check the type of key.

Previous: TTL
Next: WAIT



Follow us on Facebook and Twitter for latest update.