(10-3)redis-stringデータ型
1409 ワード
(10-3)redis-stringデータ型
redis:
[root@baozi ~]# redis-server /etc/redis.conf
[root@baozi ~]# redis-cli
127.0.0.1:6379>
redis -- string
1、 redis ;
2、 , , ( );
3、 1GB;
127.0.0.1:6379> set baozi www.hadoop.com
OK
127.0.0.1:6379> get baozi
"www.hadoop.com"
// , :
127.0.0.1:6379> setnx baozi 1
(integer) 0
127.0.0.1:6379> setnx baozi1 1
(integer) 1
127.0.0.1:6379>
// :
127.0.0.1:6379> mset name1 1 name2 2
OK
127.0.0.1:6379> mget name1 name2
1) "1"
2) "2"
127.0.0.1:6379>
// :
127.0.0.1:6379> set info "hello redis"
OK
127.0.0.1:6379> help incr
INCR key
summary: Increment the integer value of a key by one
since: 1.0.0
group: string
127.0.0.1:6379> get name1
"1"
//
127.0.0.1:6379> incr name1
(integer) 2
127.0.0.1:6379> decr name1
(integer) 1
127.0.0.1:6379>
//
127.0.0.1:6379> incrby name1 5
(integer) 6
127.0.0.1:6379> decrby name1 2
(integer) 4
//
127.0.0.1:6379> incrbyfloat name1 2.7
"6.7"
127.0.0.1:6379>
// :
127.0.0.1:6379> append info "hello world"
(integer) 22
127.0.0.1:6379> get info
"hello redishello world"
// :
127.0.0.1:6379> strlen info
(integer) 22
127.0.0.1:6379>