Redis笔记

1.set server:name "fido"

get server:name

2.set connections 10

get connections

incr connections

incr connections

del  connections

get connections

incr connections

get connections

3.set resource:lock "redis demo"

expire resource:lock 120

ttl resource:lock ttl -1 never expire,-2 doesn't exist

4.list

rpush friends "Alice"

rpush friends "Bob"

lpush friends "Sum"

lrange friends 0 1

lrange firends 1 -1

llen friends

lpop friends

rpop friends

5.set

sadd superpower "flight"

sadd superpower "x-ray vision"

sadd superpower "reflexes"

 

srem superpower "x-ray vision"

sismember superpower "flight"

smembers superpower

sadd birdpower "flight"

sadd birdpower "pecking"

sunion birdpower superpower

6.sorted set

zadd hackers 1960 "Alan Kay"

zadd hackers 1906 "Grace Hopper"

zadd hackers 1953 "Richard Stallman"

zadd hackers 1965 "Ybkihiro Matsumoto"

zadd hackers 1916 "Claude Shannon"

zadd hackers 1969 "Linus Torvalds"

zadd hackers 1957 "Sophie Wilson"

zadd hackers 1912 "Alan Turing"

 

zrange hackers 2 4

 

7.Hashes

hset user:1000 name "John Smith"

hset user:1000 email "john smith@example.com"

hset user:1000 password "s3cret"

hgetall user:1000

 

 HMSET user:1001 name "Mary Jones" password "hidden" email "mjones@example.com"

hget user:1001 name

 

hset user:1000 visits 10

hincrby user:1000 visits 1

hincrby user:1000 visits 10

hdel user:1000 visits

hincrby user:1000 visits 1

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值