I just want to know does -1 means permenent or default expire timeout.
Yes, if no timeout is set, the default TTL is -1
, and the key won't be expired. However, it might be evicted when you run out of memory, check the maxmemory-policy
configuration in redis.conf.
If setting a key value sets ttl -1 then what is the purpose of PERSIST command
You CANNOT manually set a key's TTL as -1
with EXPIRE
command. If you do that, i.e. expire key -1
, Redis will delete the key.
As you mentioned in your answer, PERSIST
is used to remove the expiration setting, and make the key persistent.