Redis Tutorial-Basic operations

Source: Internet
Author: User
Tags redis tutorial

http://try.redis.io/

Redis is Key-value storage, also known as NoSQL database, the key operation of Redis database is to store key-value data, retrieve value by key

1) storage, retrieval, deletion, self-increment set,get, DEL,INCR

> SET server:name "Fido"OK> GET server:name"Fido"> SET ConnectionsOK> INCR Connections(integer)> INCR Connections(integer)> DEL Connections(integer) 1> INCR Connections(integer) 1

2) key expires EXPIRE & TTL

#Redis can is told that aKeyShould onlyExist forA certain length ofTime. This isAccomplished withThe EXPIRE andTTL Commands. SETresource:lock "Redis Demo" EXPIRE resource:lock120
#This causes theKeyResource:lock tobe deletedinch -Seconds. Can test howLongAKeywould exist withThe TTL command. ItreturnsThe Number ofseconds until it'll be deleted. TTL Resource:lock= 113 //After 113s TTL resource:lock= -2

#The-2 forThe TTL ofTheKeymeans that theKeyDoes notexist (anymore). A-1 forThe TTL ofTheKeymeans that it'll never expire. Note thatifYouSETAKey, its TTL would be reset. SETResource:lock "Redis Demo1"EXPIRE Resource:lock -TTL Resource:lock= 119 SETResource:lock "Redis Demo2the TTL resource:lock= -1

3) sequence list Rpush, Lpush, Llen, Lrange, Lpop, and Rpop

4) Unordered collection Sadd, Srem, Sismember, Smembers and Sunion.

5) ordered set Zadd Zrange

6) hash Hset, Hgetall, Hmset, Hget, Hdel

Hincrby can perform a self-increment operation on a domain (field) inside a hash

Redis Tutorial-Basic operations

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.