Redis operations on string and hash data

Source: Internet
Author: User
Tags redis cluster install redis

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.