Storing string strings, using the Get,set command, a key for maximum storage of 512M
Store hash hash, use Hmset and Hgetall command, parameter: key, value
Example: Hmset user:1 username Taoshihan password Taoshihan
Hgetall user:1
Stores the list of lists, which can be repeated, using commands Lpush and Lrange,lpush parameters: Key, value 1, value 2 ...
Example: Lpush infos Taoshihan nan
Lrange parameters: Key, start index, end index
Example: Lrange infos 0-1 (-1 is all)
Store set collection, cannot be duplicated, use commands Sadd and smembers
Sadd parameters: Key, value 1, value 2 ...
For example: Sadd users Zhangsan Li Wangwu
Parameters of Smembers: Key
For example: Smembers users
Stores Zset ordered collections, can not be duplicated, use commands Zadd and Zrangebyscore
Zadd parameter: Key, fractional value 1 score 2 value 2 ...
Example: Zadd members 1 Zhangsan 2 Li 3 Wangwu
Zrangebyscore parameters: Key, start index, end index
Example: Zrangebyscore users 0 1
know: Redis What are the basic data structures and what are the applications?
Appl:
A brief explanation is as follows
String (strings): stores integers (such as counters) and strings (nonsense). ), some companies are also used to store serialized data such as JSON/PB, not recommended, wasting memory
Hash table (hashes): Storage configuration, objects (such as users, goods), the advantage is that you can access some key, for the frequently changing or part of the key requires the atom operation of the appropriate
List (lists): Can be used to save the latest user dynamic, the time axis, the advantage is orderly, the disadvantage is that elements can be repeated, not to heavy
Collection (sets): unordered, unique, available for demanding uniqueness
Ordered set (sorted sets): Set of ordered version, very useful, for the ranking of such complex scenarios can be considered
Bitmap (bitmaps): This is not a new data type, but it is possible to manipulate the string type in a single bit, without actually using it. 2016-03-03 Update, online Many people use bitmaps to do active user statistics and user check-in function, performance than go to the database load much higher.
Counter (hyperloglogs, translation to be determined): If the name, add element only records the number of elements, and does not store the element itself, save space and avoid repeating count, this feeling directly with the INCR can be achieved
Geospatial (Geospatial Indexes): Used for geo-location query, such as the distance between two points, a point near the number of elements, suitable for the point of comparison fixed scene, or only consider the current position of the scene, like the nearby people this is not suitable, one needs to consider a certain period of time points, Second, the point is often updated, the pressure ratio is large
[Redis] Data types for Redis