DEL key [key ...]
Removes the specified keys. A key is ignored if it does not exist.
fruits key containing our list:
redis> del fruits (integer) 1
Create two keys and delete them:
redis> set visitor1 "John Smith" OK redis> set visitor2 "Jane Doe" OK redis> del visitor1 visitor2 (integer) 2
Read more about the DEL command in the Redis documentation.
Returns the remaining time to live of a key that has a timeout. This introspection capability allows a Redis client to check how many seconds a given key will continue to be part of the data set.
For example, let's return to a previous example. Recall that
SET key value [EX seconds] sets the specified expire time of the cached item in seconds. Let's set our
dog key/value pair to live for 120 seconds.
redis> set dog "Old Yeller" EX 120 OK
As an interesting side note, we could also accomplish the expire time as follows:
redis> set dog "Old Yeller" OK redis> expire dog 120 (integer) 1
Next, we can use the
TTL command to see how much time remains before the
dog key expires:
redis> ttl dog (integer) 112 OK
We see that 112 seconds remain before the
dog key expires. Very nice! The
TTL command provides visibility so we can ascertain when a given key will expire from the Redis cache.
Read more about the TTL command in the Redis documentation.