标签:https alice star returns union members nio sub ash
SET server:name "fido"
=> "fido"
EXISTS server:name
=> 1
EXISTS server:blabla
=> 0
原子性,同时发生的事务不会影响正确结果
INCR a
=> 1
DECR a
=> 0
INCRBY a 100
=> 100
DECRBY a 100
=> 0
SET a 100
GET a
=> "100"
DEL a
INCR a
=> 1
EXPIRE a 120 (expired in 120s)
TTL a (returns the number of seconds until it will be deleted)
(-2 shows it has expired and -1 shows permanent)
SET a 100 EX 5
PERSIST a
TTL a
=> -1
RPUSH puts the new element at the end of the list.
RPUSH friends "Alice"
LPUSH puts the new element at the start of the list.
LPUSH friends "Bob"
LRANGE subset of the list 类似substring
LRANGE friends 0 -1 => 1) "Sam", 2) "Alice", 3) "Bob"
LRANGE friends 0 1 => 1) "Sam", 2) "Alice"
LRANGE friends 1 2 => 1) "Alice", 2) "Bob"
LPOP removes the first element from the list and returns it.
RPOP removes the last element from the list and returns it.
LLEN return length of the list.
SADD adds the given member to the set 可多个参数同时添加,0存在 1不存在
SREM removes the given member from the set 1存在,0不存在
SISMEMBER tests if the given value is in the set 1存在,0不存在
SMEMBERS returns a list of all the members of this set.
SUNION 合并两个或多个,返回一个包含所有元素的集合,相同项只会保留一个
SPOP 随机删除元素 可以设置个数
SADD letters a b c d e f => 6
SPOP letters 2 => 1) "c" 2) "a"
SRANDMEMBER 返回随机元素 可以设置个数
ZADD ZRANGE…
HSET 添加元素 HMSET 添加多个元素
HSET user:1000 name "John Smith"
HGET 获得元素 HGETALL 全部元素
HGET user:1001 name => "Mary Jones"
HGETALL user:1000 (键和值会分开输出?)
=> 1) "name" 2) "John Smith" 3) "email" 4) "john.smith@example.com" 5) "password" 6) "s3cret"
Numerical value操作
HSET user:1000 visits 10 HINCRBY user:1000 visits 1 => 11 HINCRBY user:1000 visits 10 => 21 HDEL user:1000 visits HINCRBY user:1000 visits 1 => 1
Check out the following links to continue learning about Redis.
标签:https alice star returns union members nio sub ash
原文地址:https://www.cnblogs.com/Zeiion/p/14839254.html