Redis operations on string and hash data
Set name xiaohongyang //
Get name
Setnx name xiaohy
Get name
Setex name 10 jackxiao
Set email xiaohy@yahoo.com
Get email
Setrange email 7 qq.com
Get email
Mset name xhy sex man age 30 // set multiple key values in batches
Get name
Get sex
Get age
Msetnx name xhy1 setx man age 28 city suzhou
Msetnx name1 xhy1 setx man age1 28 city suzhou
Getset name xhy_new // get the current value of the string and set a new value for it
Getrange email 7-1 // obtain the substring of the string
Mget name sex age // obtain multiple key values in batches
Incr age // Add 1 to the key value
Incrby age-5 // specify the key value
Decr age // subtract 1 from the key value
Decrby age 5 // specify the key value
Append name. com // append string to the string
Strlen name // obtain the string length
Hset user: 1 name xiao // set the key value of the hash table
Hget user: 1 name // obtain the key value of the hash table
Hsetnx user: 1 sex man // determines whether the key value of the hash table exists. If it does not exist, Set
Hget user: 1 sex
Hmset user: 1 age 30 email 258082291@qq.com
Hmet user: 1 name age sex email
Hincrby user: 1 age 5
Hexists user: 1 age
Hlen user: 1 // return the number of keys in the hash table
Hdel user: 1 age // key used to delete the hash table
Hkeys user: 1 // return all keys of the hash table
Hvals user: 1 // return all values of the hash table
Hgetall user: 1 // return all key and value values in the hash.
Recommended reading:
Redis cluster details
Install Redis in Ubuntu 12.10 (graphic explanation) + Jedis to connect to Redis
Redis series-installation, deployment, and maintenance
Install Redis in CentOS 6.3
Redis. conf
Redis details: click here
Redis: click here