Search code examples
redisredis-cliredis-server

redis,set a value to 3,but its type is string


I use redis 6.2.4,in the redis-cli i input command:

127.0.0.1:6379> set k5 3
OK
127.0.0.1:6379> type k5
string
127.0.0.1:6379> 

why the type of k5 is string but not number?


Solution

  • number is not a Redis (data) type.

    I'm adding some links for your reference:


    OBJECT ENCODING command may suit your need.

    127.0.0.1:6379> set k5 3
    OK
    127.0.0.1:6379> OBJECT ENCODING k5
    "int"