1. String type
Description: String is the simplest type and you can understand that it is the exact same type as memcached, and a key corresponds to a value. Memcached can be fully implemented, and the efficiency is much higher than the memcached, and can set up the Redis timing data persistence,
Record of operation log and functions such as master-slave copy.
Method:
1. Set setting key corresponds to a value of type string, such as: Set name test001
2. Setnx sets the value of the key corresponding to string type. If key already exists, return 0,nx is not exist meaning as Setnx name test001 return value is (integer) 0
3. Setex sets a value for a key and sets an expiration date for this key-value pair. For example: Specify a key value to name = test001, and set a validity period of 10 seconds Setex name Ten test001
4. SETRANGE sets the substring of the value of the specified key, such as changing the name to test002 SetRange Name 3 002
5. Mset set multiple key-value pairs at the same time, successful return OK means all key settings are successful, and failure returns 0 to indicate that all key settings are unsuccessful, such as Mset name1 test001 name2 test002
6. MSETNX also set multiple key-value pairs, the same failure returned 0 means that all keys are not set successfully, the successful return of OK means that all keys are set successfully, but unlike Mset, this method does not reset the existing key-value pairs !
7. Get gets the value corresponding to a key and returns nil if it does not exist
8. Getset sets the value of a key, returns the old value of the key, returns nil if the key does not exist, and then sets the new value. returns the old value, setting the new value.
9. GetRange gets a substring of the value of the specified key, such as GetRange name 0 3 The return value of the test number refers to the subscript, or negative, when the subscript exceeds the length of the string, it is assumed to be the largest subscript in the same direction.
Mget gets the value of multiple keys at once, and returns nil if the key does not exist
INCR the value of a key and returns a new value, if the value of the key is not of type int, it will be an error, if the key does not exist, set the key to 1
Incrby is similar to INCR, but Incrby can specify an increased value to return the most recent value. For example, Incrby age 5 5 represents an increase of 5 for the Age key, and 1 for the age key minus 1, which is a positive number plus a minus
DECR to a certain key to reduce the operation, the same incr
Decrby with Incrby, give a key minus the specified value
Append appends value to the string value of the specified key, returning the length of the new string value, such as set name test; Append name 001; return result test001
Strlen takes the length of the value of the specified key. Strlen Name 6
Http://bbs.lampbrother.net/read-htm-tid-122275-ds-1.html
Redis data Type--strings (string)