Redis study notes (five) ---- Redis Command Description

Foreword

Redis look at general command description

A. Redis supports five data types

string (string), hash (hash), list (list), set (collection) and zset (sorted set: an ordered collection), etc.

Two. Redis key key

(1) Redis key commands for managing redis key
(key name is case insensitive)

[1] del key: This key is present when the command for deleting the key
[2] the dump key: the sequence of a given key, and return the serialized value
[3] exists key: Check whether there is a given key
[4] expire key seconds: the given key expiration time (in seconds)
(if the expiration time is not set, returns -1 when compared with the permanent key performs TTL.)
[. 5] pexpire key milliseconds: set the expiration time of the key to milliseconds.
[6] ttl key: in seconds, returns the given key remaining lifetime (TTL Time to Live)
(permanent behalf -1, -2 means invalid)
[. 7] pptl key: milliseconds returns the key remaining expiration time
[8] persist key: remove the key expiration time, key will persist
[9] keys pattern:
Find all match a given pattern (pattern) is key
to all the key wildcard pattern matching key acquisition, returns all matches with the mode key
wildcards:
* for all
represent a character?

[10] the rename key newkey: change the name key in
[11] move key db: the current key to move the database to a specified database db them
[12] type key: the return type of the stored value key

(2) application scenarios
The expire seconds The Key
[1] limited-time promotions information
[2] website data cache (for some of the data need to be updated, such as: scoreboard)
[3] phone verification code
[4] to limit access to site visitors frequency (e.g.: 1 minute up to 10 access)

(. 3) key name suggestions:
Redis key may be stored in a single size of 512 M
[. 1] key is not too long, so as not to exceed 1024 bytes, which not only consumes memory, and reduce the search efficiency
[2] is also not too short key , too short, key reduces readability
[3] in one project, key consistent naming scheme is preferably used, for example, user: 123: password

Published 25 original articles · won praise 2 · Views 1180

Guess you like

Origin blog.csdn.net/TheWindOfSon/article/details/104116929