the data type of redis
2017-06-07 00:00
288 查看
exists key
del key
type key
keys * ? [a-b] \?
1.String
set key value
get key
incr key
incrby key increment
incrbyfloat key increment
decr key
decrby key decrement
append key value
strlen key
mset key value [ key value... ]
mget key [ key ... ]
getbit key offset
setbit key offset value
bitcount key [ start ] [ end ] // the counts from the start byte to end byte
bitop operation result key1 key2 // the operation include " and or xor not "
bitpos key bitValue(0 or 1) [ start ] [ end ] // get the bit position whose value is bitValue of the key begin with the start byte and end up with the end byte
2.Hash ( key field value [ field value ... ])
hset key field value
hget key field
hmset key field value [ field value ... ]
hget key field [ field ... ]
hgetalll key
hexists key field
hsetnx key field value // like the command hset , the distinction is if field exists then the command hsetnx do nothing
hincrby key field increment
hdel key field [ filed ... ]
hkeys key // get all the field of the key
hvals key // get all the value of the key
hlen key // get all
3.List (the inside structure is doubly linked list)
lpush key value [ value ... ]
rpush key value [ value ... ]
lpop key
rpop key
llen key // the element number of key
lrange key start end
/*
* when count > 0 then delete the first count element which element is value of the key on the left
*when count< 0 then delete the last abs(count) element which element is value of the key on the right
*when count=0 then delete all the element which field is value
*/
lrem key count value
lindex key index // get the index element of the key
lset key index value // set the result of the index element is value of the key(list)
linsert key before | after pivot value // find the result is pivot from left to right ,then according to the before or after to insert
rpoplpush source destination // pop one element on the right from source to push one element on the left for the destination every time
4.set ( inside structure is hash table : disorder 、unique)
sadd key member [ member ... ] // if key is not exists then create it , if the member is exists ,then ignore it
srem key member [ member ...] // if member is exists then pop it ,else ingore it
smembers key // show all the members
sismember key member // judge the member is or not exists
sdiff key [ key ... ] // subtract
sinter key [ key ... ] // intersect
sunion key [ key .... ] // union
scard key // get the number of the set
sdiffstore destination key [ key ... ] // function equeals sdiff , the distinction is sdiffstore don't show the result ,but counld set the result to destination
sinterstore destination key [ key ... ] // same as above
sunionstore
4000
destination key [ key ... ] // same as above
/*
* when count > 0 , then get count numbers different random elements from set , if count is greater than the size of set , then show all the elements
* when count < 0 , then get |count| numbers random elements from set , but the elements maybe equal to each other
*/
srandmember key count
spop key // pop a random element of the set
5.zset ( ordered set )
zadd key score member [ score member .. ] // add one or more member and score of the member to the ordered set called key
zscore key member // get the score of the member
zrange key start stop [ withscores ] // get the start index to end index members of order set from small to large
zrevrange key start stop [ withscores ]
zrangebyscore key min max [ withscore ] [ limit offset count ] // get the member of ordered set that the score between min and max
example : zrangebyscore score 80 100
zrangebyscore score 80 (100
zrangebyscore score (80 +inf
zrangebyscore score -inf +inf
zrangebyscore score 80 100 limit 1 3
zrevrangebyscore score 100 0 limit 0 3 // get the top three members whose score less than or equal to 100
zincrby key increment member // make the score of the member belong to the zset to add ' increment '
zcard key /// get the counts of the zset
zcount key min max // get the counts between the min and max of the zset
zrem key member [ member ... ] // del the one or more member
zremrangebyrank key start top // del the members from start index to top index according to the score from small to large
zremrangebyscore key min max // del the member according to the score between min and max
zrank key member // get the rank of the member that had ordered from small to large
/*
* get the intersection include key and key ...
* weights means the score need multiply the weight everyone
* aggregage means to get the sum | min | max with the key and key
*/
zinterstore destination numkeys key [ key ... ] [ weights weight [weight ...] ] [ aggregate sum | min | max ]
zunionstroe destination numkeys key [ key ... ] [ weights weight [ weight ... ] ] [ aggregate sum | min | max ] // like zinterstore
del key
type key
keys * ? [a-b] \?
1.String
set key value
get key
incr key
incrby key increment
incrbyfloat key increment
decr key
decrby key decrement
append key value
strlen key
mset key value [ key value... ]
mget key [ key ... ]
getbit key offset
setbit key offset value
bitcount key [ start ] [ end ] // the counts from the start byte to end byte
bitop operation result key1 key2 // the operation include " and or xor not "
bitpos key bitValue(0 or 1) [ start ] [ end ] // get the bit position whose value is bitValue of the key begin with the start byte and end up with the end byte
2.Hash ( key field value [ field value ... ])
hset key field value
hget key field
hmset key field value [ field value ... ]
hget key field [ field ... ]
hgetalll key
hexists key field
hsetnx key field value // like the command hset , the distinction is if field exists then the command hsetnx do nothing
hincrby key field increment
hdel key field [ filed ... ]
hkeys key // get all the field of the key
hvals key // get all the value of the key
hlen key // get all
3.List (the inside structure is doubly linked list)
lpush key value [ value ... ]
rpush key value [ value ... ]
lpop key
rpop key
llen key // the element number of key
lrange key start end
/*
* when count > 0 then delete the first count element which element is value of the key on the left
*when count< 0 then delete the last abs(count) element which element is value of the key on the right
*when count=0 then delete all the element which field is value
*/
lrem key count value
lindex key index // get the index element of the key
lset key index value // set the result of the index element is value of the key(list)
linsert key before | after pivot value // find the result is pivot from left to right ,then according to the before or after to insert
rpoplpush source destination // pop one element on the right from source to push one element on the left for the destination every time
4.set ( inside structure is hash table : disorder 、unique)
sadd key member [ member ... ] // if key is not exists then create it , if the member is exists ,then ignore it
srem key member [ member ...] // if member is exists then pop it ,else ingore it
smembers key // show all the members
sismember key member // judge the member is or not exists
sdiff key [ key ... ] // subtract
sinter key [ key ... ] // intersect
sunion key [ key .... ] // union
scard key // get the number of the set
sdiffstore destination key [ key ... ] // function equeals sdiff , the distinction is sdiffstore don't show the result ,but counld set the result to destination
sinterstore destination key [ key ... ] // same as above
sunionstore
4000
destination key [ key ... ] // same as above
/*
* when count > 0 , then get count numbers different random elements from set , if count is greater than the size of set , then show all the elements
* when count < 0 , then get |count| numbers random elements from set , but the elements maybe equal to each other
*/
srandmember key count
spop key // pop a random element of the set
5.zset ( ordered set )
zadd key score member [ score member .. ] // add one or more member and score of the member to the ordered set called key
zscore key member // get the score of the member
zrange key start stop [ withscores ] // get the start index to end index members of order set from small to large
zrevrange key start stop [ withscores ]
zrangebyscore key min max [ withscore ] [ limit offset count ] // get the member of ordered set that the score between min and max
example : zrangebyscore score 80 100
zrangebyscore score 80 (100
zrangebyscore score (80 +inf
zrangebyscore score -inf +inf
zrangebyscore score 80 100 limit 1 3
zrevrangebyscore score 100 0 limit 0 3 // get the top three members whose score less than or equal to 100
zincrby key increment member // make the score of the member belong to the zset to add ' increment '
zcard key /// get the counts of the zset
zcount key min max // get the counts between the min and max of the zset
zrem key member [ member ... ] // del the one or more member
zremrangebyrank key start top // del the members from start index to top index according to the score from small to large
zremrangebyscore key min max // del the member according to the score between min and max
zrank key member // get the rank of the member that had ordered from small to large
/*
* get the intersection include key and key ...
* weights means the score need multiply the weight everyone
* aggregage means to get the sum | min | max with the key and key
*/
zinterstore destination numkeys key [ key ... ] [ weights weight [weight ...] ] [ aggregate sum | min | max ]
zunionstroe destination numkeys key [ key ... ] [ weights weight [ weight ... ] ] [ aggregate sum | min | max ] // like zinterstore
相关文章推荐
- redis.clients.jedis.exceptions.JedisDataException: WRONGTYPE Operation against a key holding the wrong kind of value
- The model item passed into the dictionary is of type 'System.Collections.Generic.List`1[BMS.DataAccess.Models.ServiceTyp
- ADO.NET Entity Framework: The version of SQL Server in use does not support datatype 'datetime2'
- The version of SQL Server in use does not support datatype 'datetime2'.
- redis WRONGTYPE Operation against a key holding the wrong kind of value
- The size of base data type in Ubuntu-AMD64
- The conversion of a varchar data type to a datetime data type resulted in an out-of-range value
- the application is not licensed to create or modify schema for this type of data
- The content of element type "struts-config" must match "(display-name?,description?,data-sources?,fo
- [entity framework ] The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.
- ERROR: The version of SQL Server in use does not support datatype 'datetime2'.
- The Fundamentals of the SQL Server 2005 XML Datatype
- The application is not licensed to modify or create schema for this type of data 解决办法
- The conversion of a datetime2 data type to a datetime data type resulted in an out-of-range value. 错误的原因及解决方案
- ArcGIS Engine中初始化许可常见问题归纳,the application is not licensed to create or modify schema for this type of data
- HOW TO: Change the Owner of a User-Defined Data Type That Is in Use in SQL Server 2000
- 完全解决struts启动时报错:The content of element type "struts-config" must match "(data-sources?,form-beans?,global-exceptions?,global-for
- Error: The version of SQL Server in use does not support datatype 'datetime2
- 海洋工作室——网站建设专家:The version of SQL Server in use does not support datatype datetime2 and the Entity Framework.
- Objective-C determine data network type of the iOS device