To clear Memcached data, you can either delete individual keys or flush all keys. Here's how to do it:
You can delete a single key from Memcached using the delete
command. The syntax for the command is as follows:
delete <key> [time]
<key>
- The name of the key you want to delete[time]
- An optional expiration time for the key. If you specify an expiration time, the key will be deleted after that many seconds.Here's an example of deleting a key named my_key
:
$ telnet localhost 11211
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
delete my_key
DELETED
If you want to clear all keys from Memcached, you can use the flush_all
command. This command will remove all keys from the cache. The syntax for the command is as follows:
flush_all [time]
[time]
- An optional expiration time for all keys. If you specify an expiration time, all keys will be deleted after that many seconds.Here's an example of flushing all keys:
$ telnet localhost 11211
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
flush_all
OK
Note that flushing all keys will remove all items from the cache, so use it with caution.
Dragonfly is fully compatible with the Redis ecosystem and requires no code changes to implement.