Redis Learning Notes (add and subtract) adds a key to the database
SET key value
Get the key in the database
KEYS pattern
Pattern supports GLOB style wildcard format
"?" matches one character
"*" matches any character
"[]" matches any one of the characters between parentheses, you can use the "-" symbol to represent a range, for example: A[a-z]c
"\x" matches the character X, which is used to escape characters. If you need to match "?", you need to use \?
Keys * (deprecated, queries can affect performance if too many keys are in the library)
Determine if a key exists
How to exist returns 1, does not exist return 0:
redis> Exists key
(integer) 1
Delete key
Redis> del key ... .
Multiple keys can be deleted at the same time, the number of deleted keys will be returned, and if no this key will return 0
High-performance removal
The DEL command does not support wildcards and can be combined with the Linux pipeline and the Xargs command to remove all rules-compliant keys
For example: Delete all keys that begin with "haha:".
Under the Linux command line:
redis-cli KEYS "haha:*" | xargs redis-cli DEl (单个key作为参数)redis-cli del ‘redis-cli keys "haha:*"‘ (多个键作为参数..没测成功)
Gets the data type of the key value
TYPE *key*
The return value may be string (string type), hash (hash type), list (list type), set (collection type), Zset (ordered collection type)
Redis Learning Notes (additions and deletions)