Redis supports the following data structures: strings, lists, hashes, set, and sortedset. The following are specific operations for strings: getsetsetnx, append,
Data Structures Supported by redis: strings, lists, hashes, set, sorted set. The specific operations for strings are as follows: get/set/setnx, append,
Data Structures Supported by redis: strings, lists, hashes, set, sorted set. Next we will do the experiment one by one.
Strings operations include get/set/setnx, append, strlen, getrange/setrange, incr/decr/incrby/decrby, mget/mset.
Get/set is to insert data (key-value corresponds ):
Setnx is used to insert data to check whether the same key value exists. If yes, 0 is returned. If no value exists, 1: append is returned, which is a simple append character: getrange/setrange is a simple string operation that retrieves or sets the character at the relative position. There was a problem during the experiment here, mainly because we were not familiar with the setrange operation. Let's take a look at the following operation and we will understand that setrange is used to replace the number of corresponding positions, the location of 5 is @, and QQ.com is 6 characters to replace mysina. com10 characters can only Replace the first six. Incr/decr/incrby/decrby means that the incrby/decrby after auto-increment and auto-subtraction are added with the step size. If there is no key value, it can also be operated: mget/mset indicates batch insertion and removal.
The basic operations of a hash table are the same as those of a string, such as hget/hset/hsetnx, happend, hstrlen, hgetrange/hsetrange, hincr/hdecr/hincrby/hdecrby, and hmet/hmset, just add H to the front. It is especially suitable for storing object data. The basic operation is the same as above. Here the key is used as the hash name. During the operation, you need to provide the hash field you want to insert:
Other operations are the same as above: