4 Ways to Return a Key’s Expiry in Redis

There are several ways to return a key’s expiry in Redis. The method used depends on how we want the expiry to be returned.

We can use the TTL command to return the timeout in seconds. We can alternatively use the PTTL command to return it in milliseconds. Another way to do it is to use the EXPIRETIME which returns the absolute Unix timestamp of the key in seconds, or the PEXPIRETIME command which returns the absolute Unix timestamp of the key in milliseconds.

Continue reading

Redis DUMP Command Explained

The Redis DUMP command serialises the value stored at a specified key in a Redis-specific format and returns it to the user.

The serialisation format contains a 64-bit checksum that is used to make sure errors will be detected. The values are in the same format used by the RDB. Also, an RDB version is encoded inside the serialised value, so that different Redis versions with incompatible RDB formats will refuse to process the serialised value.

Continue reading