One complaint: Don't actually use the KEYS command. It's not very efficient. Instead, keep a set of all the keys you would want to delete. When you call KEYS, it has to do a linear scan of every key in the database, and since it is stored as a hash table there really isn't a way to optimize it. It's useful for inspecting things in redis-cli, but not much else.