Redis: keys
Key distribution
> INFO KEYSPACE
# Keyspace
db0:keys=6,expires=6,avg_ttl=901955
Key listing
> KEYS *
1) "c470f6a64f5109e068a74231a643608f8f8ab50c3e1c3668fe87e9cd7282bbd8"
2) "8c13aad33a0f9e8245df16d9227308b171d20829b254d8801ab6ed49f3a9f5b2"
Key creation and deletion
> SET mykey "myvalue"
> GET mykey
"myvalue"
> DEL mykey
Delete all keys (redis > 2.6):
> EVAL "for i, name in ipairs(redis.call('KEYS', '*')) do redis.call('DEL', name); end" 0
TTL of a key
In seconds:
> TTL c470f6a64f5109e068a74231a643608f8f8ab50c3e1c3668fe87e9cd7282bbd8
(integer) 438
In milliseconds:
> PTTL c470f6a64f5109e068a74231a643608f8f8ab50c3e1c3668fe87e9cd7282bbd8
(integer) 434170