1.1 Data types
There are five data types used by Redis: string, hash, list, set, Zset (sorted set).
Redis internally uses a Redisobject object to represent all keys and value, redisobject the most important information as shown in
The type represents what data type a value object is, and encoding is how different data types are stored inside the Redis, such as: Type=string represents a normal string for value. Then the corresponding encoding can be raw or int, and if it is an int, the actual redis internal is stored and represented by a numeric class, assuming that the string itself can be represented numerically, such as a string such as "123" "456".
Open Redis source scr/sds.h See the structure of string type (note; The following are the source of redis-3.0)
Type is the corresponding 5 data types and is already defined.
1.1.1 String Type
- 1. String data type
The string is the simplest type, and a key corresponds to a value,string type of data up to 1G. A string type can be treated as an integer, allowing the "INCR" command family to operate (Incrby, DECR, Decrby), in which case the value of the integer is limited to 64-bit signed numbers. The separate element types contained in list, set, and Zset are Redis string types.
- 2. String data Structure
Open Redis Source Scr/sds.h View the structure of the string type
Len: The length of the tag char[] is somewhat similar to the size of the list in our C #.
Free: The number of unused elements in the tag char[] is the meaning of a few empty pits.
Buf[]: The hole that holds the element is not necessarily equal to the actual number of elements, such as the Cnblogs mentioned earlier. It may also be [c][n][b][l][o][g][s][/0][][][].
- 3. String data type common commands
Resids related commands can refer to the website information http://doc.redisfans.com/
Redis Data Type Summary-string