redis基本命令

1.设置与获取

127.0.0.1:6379>set1"ab"

OK

127.0.0.1:6379>get1

"ab"

127.0.0.1:6379>append1bc

(integer)3

127.0.0.1:6379>get1

"abc"

2.同时设置与获取多个key

127.0.0.1:6379>mset1a2b3c

OK

127.0.0.1:6379>get2

"b"

127.0.0.1:6379>mget123

1)"a"

2)"b"

3)"c"

3.字段赋值:

127.0.0.1:6379>hsetcar1namec1

(integer)1

127.0.0.1:6379>hgetcar1name

"c1"

127.0.0.1:6379>hmsetcar1namec1price100

OK

127.0.0.1:6379>hgetallcar1

1)"name"

2)"c1"

3)"price"

4)"100"

127.0.0.1:6379>hincrbycar1price200

(integer)300

4.判断是否存在:

127.0.0.1:6379>hexistscar1name

(integer)1

5.删除记录:

127.0.0.1:6379>hdelcar1price

(integer)1

127.0.0.1:6379>hgetallcar1

1)"name"

2)"c1"

6.显示所有的key或value

127.0.0.1:6379>hkeyscar1

1)"name"

127.0.0.1:6379>hvalscar1

1)"c1"

7.增减数值

127.0.0.1:6379>setnum1

OK

127.0.0.1:6379>incrnum

(integer)2

127.0.0.1:6379>incrbynum2

(integer)4

127.0.0.1:6379>decrnum

(integer)3

127.0.0.1:6379>decrbynum2

(integer)1

127.0.0.1:6379>incrbyfloatnum0.5

"1.5"

相关推荐