The article belongs to the blog park and the author "snail" Common all. Reprint and crawler Please specify the original Redis series link http://www.cnblogs.com/tdws/tag/NoSql/
There are five basic data types of Redis. They are strings, hashes, lists, collections, and ordered collections , respectively. In fact, the last four kinds, on our surface, seem to be organized in different forms to organize string key values.
You can use it to store any piece of data you want, which is the overall data yo. If it is the title of the article, tags, content, comments such as data, although you can serialize its objects into JSON storage, but do not recommend the use of strings. Because as a whole storage, when you want to get any of them, such as the title or the author, you need to get the entire article data and the transfer volume is much larger, then deserialize, and get the title. You can even store Base64 a class of pictures and so on. Most commonly used like user name, password, email, verification code and so on. A string key allows storage of up to 512MB of data.
Set key value
Keys * Lists all keys keys and is not recommended for use in production environments.
keys supports wildcard symbols
Use * to match any of the characters (including 0)
Use [] match range
Use ? matches any one character. Note that it's a " one ".
There is also a \x escape character, which is used when you need to take the contents of an escaped symbol.
exists to determine whether there are several returned corresponding numbers
del keys delete keys to delete several returned corresponding numbers
Type Key returns the types of key
get keys get key values only for strings yo
incr key increments the number, and the INCR key is run autonomously with get set. See my Redis concurrency lock article for details. If a key that does not exist defaults to 0, the instruction operates with a value of 1 and returns the incremented value.
Incrby key increments the specified value, returning the result after the increment.
DECR Decrby are all subtraction.
Append key val concatenation value, and finally returns the string length.
strlen Gets the string length of the value of the key.
Mset mget store and get multiple key values at once
Summary : A brief introduction to basic string type operations and results. There's a bit of operation that hasn't been used. The INCR command can be used in the case of the ID of the article, the statistics of the traffic, etc., and the concurrency race will not occur.
In addition, in our custom, we named Redis key by object type: Object ID: Object property .
For example: Artical:4001:viewcount article 4001 visits PROJECT:1001:PM Project 1001 PM book:9001:author.name book 9001 author name
Redis Command Supplements one (string type)