[Chapter 3] Strings (Redis)

Source: Internet
Author: User

[Email protected]:~$ cd redis-2.8.12

[Email protected]:~/redis-2.8.12$ cd src

[Email protected]:~/redis-2.8.12/src$ redis-cli


Set

Redis 127.0.0.1:6379> Get Name

"Lijie"

Redis 127.0.0.1:6379> Set name Michael

Ok


Get

Redis 127.0.0.1:6379> Get Name

"Michael"

Redis 127.0.0.1:6379> setnx name Micahel

(integer) 0


Setnx

Redis 127.0.0.1:6379> setnx Age 10

(integer) 1

Redis 127.0.0.1:6379> Setex Date 10 2010

Ok

Redis 127.0.0.1:6379> Get Date

"2010"

Redis 127.0.0.1:6379> Get Date

(nil)

Redis 127.0.0.1:6379> Set email [email protected]

Ok

Redis 127.0.0.1:6379> Get Email

"[Email protected]"


SetRange

Redis 127.0.0.1:6379> SetRange Email 8 qq.com

(integer) 18

Redis 127.0.0.1:6379> Get Email

"[Email protected]"


Mset

Redis 127.0.0.1:6379> Mset key1 M1 key2 m2

Ok

Redis 127.0.0.1:6379> Get Key1

"M1"

Redis 127.0.0.1:6379> Get Key2

"M2"

Redis 127.0.0.1:6379> Get Key2

"M2"

Redis 127.0.0.1:6379> Get Key3

(nil)


Msetnx

Redis 127.0.0.1:6379> msetnx key4 unisys.com key5 jasson.net key3 m3 key2 m2

(integer) 0

Redis 127.0.0.1:6379> Get Key4

(nil)

Redis 127.0.0.1:6379> msetnx key4 unisys.com key5 jasson.net key3 m3

(integer) 1

Redis 127.0.0.1:6379> Get Key1

"M1"


GetRange

Redis 127.0.0.1:6379> getrange key1 0 1

"M1"

Redis 127.0.0.1:6379> getrange key1 0 0

"M"


Getset

Redis 127.0.0.1:6379> Getset Key1 20

"M1"


Mget

Redis 127.0.0.1:6379> mget key1 key2 Key3 key4 key5

1) "20"

2) "M2"

3) "M3"

4) "Unisys.com"

5) "Jasson.net"


incr

Redis 127.0.0.1:6379> incr Key6

(integer) 101

Redis 127.0.0.1:6379> incr Key6

(integer) 102

Redis 127.0.0.1:6379> Get Key6

"102"


Incrby

Redis 127.0.0.1:6379> Incrby Key6 1

(integer) 103

Redis 127.0.0.1:6379> Incrby Key6 2

(integer) 105

Redis 127.0.0.1:6379> Incrby key6-2

(integer) 103


Decr/decrby

Redis 127.0.0.1:6379> DECR Key6 1

(Error) ERR wrong number of arguments for ' decr ' command

Redis 127.0.0.1:6379> DECR Key6

(integer) 102

Redis 127.0.0.1:6379> Decrby Key6 1

(integer) 101


Append

Redis 127.0.0.1:6379> Get Name

"Michael"

Redis 127.0.0.1:6379> append name. Net

(integer) 11

Redis 127.0.0.1:6379> Get Name

"Michael.net"


Strlen

Redis 127.0.0.1:6379> strlen Name

(integer) 11


This article is from the "Software Design and Development" blog, please be sure to keep this source http://yuanzhitang.blog.51cto.com/2769219/1783090

[Chapter 3] Strings (Redis)

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.