CentOS 7
Ads

Redis : Basic Usage#4
2016/07/21
 
This is the Basic Usage of Redis with "redis-cli" client program.
Following examples are basic one, you can see more commands on Official Site below.
⇒ http://redis.io/commands
[1] This is the basic Usage of Hash tables.
[root@dlp ~]#
redis-cli -a password
# set Value of a Hash field
127.0.0.1:6379> hset hash01 field01 value01 
(integer) 1

# get Value of a Hash field
127.0.0.1:6379> hget hash01 field01 
"value01"

# set some Values of some Hash fields
127.0.0.1:6379> hmset hash01 field02 value02 field03 value03 
OK

# get some Values of some Hash fields
127.0.0.1:6379> hmget hash01 field01 field02 field03 
1) "value01"
2) "value02"
3) "value03"

# get all fields of a Hash table
127.0.0.1:6379> hkeys hash01 
1) "field01"
2) "field02"
3) "field03"

# get all values of fields of a Hash table
127.0.0.1:6379> hvals hash01 
1) "value01"
2) "value02"
3) "value03"

# get all values and fields of a Hash table
127.0.0.1:6379> hgetall hash01 
1) "field01"
2) "value01"
3) "field02"
4) "value02"
5) "field03"
6) "value03"

# increment integer Value of a Hash field
127.0.0.1:6379> hincrby hash01 field04 100 
(integer) 101

# determine if a hash field exists or not
127.0.0.1:6379> hexists hash01 field01 
(integer) 1

# get number of fields of a Hash
127.0.0.1:6379> hlen hash01 
(integer) 4

# remove specified field of a Hash
127.0.0.1:6379> hdel hash01 field04 
(integer) 1
 
Tweet