APPEND key value
Available since 2.0.0, Time complexity: O(1).
Append a value to a key
127.0.0.1:6379> SET foo hello OK 127.0.0.1:6379> APPEND foo world (integer) 10 127.0.0.1:6379> GET foo "helloworld" 127.0.0.1:6379> APPEND bar hello (integer) 5 127.0.0.1:6379> GET bar "hello"
More: http://redis.io/commands/append, http://www.redis.cn/commands/append.html
BITCOUNT key [start end]
Count set bits in a string
127.0.0.1:6379> SET foo hello OK 127.0.0.1:6379> BITCOUNT foo (integer) 21
More: http://redis.io/commands/bitcount, http://www.redis.cn/commands/bitcount.html
BITOP operation destkey key [key ...]
Perform bitwise operations between strings
127.0.0.1:6379> SET key1 aba OK 127.0.0.1:6379> SET key2 abb OK 127.0.0.1:6379> BITOP OR dest key1 key2 (integer) 3 127.0.0.1:6379> GET dest "abc"
More: http://redis.io/commands/bitop, http://www.redis.cn/commands/bitop.html
BITPOS key bit [start] [end]
Find first bit set or clear in a string
127.0.0.1:6379> SET foo "\xff\xf0\x00" OK 127.0.0.1:6379> BITPOS foo 0 (integer) 12 127.0.0.1:6379> SET foo "\x00\xff\xf0" OK 127.0.0.1:6379> BITPOS foo 1 (integer) 8
More: http://redis.io/commands/bitpos
DECR key
Decrement the integer value of a key by one
127.0.0.1:6379> SET foo 10 OK 127.0.0.1:6379> DECR foo (integer) 9 127.0.0.1:6379> DECR foo (integer) 8 127.0.0.1:6379> DECR bar (integer) -1
More: http://redis.io/commands/decr, http://www.redis.cn/commands/decr.html
DECRBY key decrement
Decrement the integer value of a key by the given number
127.0.0.1:6379> SET foo 10 OK 127.0.0.1:6379> DECRBY foo 3 (integer) 7 127.0.0.1:6379> DECRBY foo 4 (integer) 3
More: http://redis.io/commands/decrby, http://www.redis.cn/commands/decrby.html
GET key
Get the value of a key
127.0.0.1:6379> GET foo (nil) 127.0.0.1:6379> SET foo hello OK 127.0.0.1:6379> GET foo "hello"
More: http://redis.io/commands/get, http://www.redis.cn/commands/get.html
GETBIT key offset
Returns the bit value at offset in the string value stored at key
# binary of code a's ASCII is 01100001 127.0.0.1:6379> SET foo a OK 127.0.0.1:6379> GETBIT foo 0 (integer) 0 127.0.0.1:6379> GETBIT foo 1 (integer) 1 127.0.0.1:6379> GETBIT foo 2 (integer) 1 127.0.0.1:6379> GETBIT foo 3 (integer) 0 127.0.0.1:6379> GETBIT foo 4 (integer) 0 127.0.0.1:6379> GETBIT foo 5 (integer) 0 127.0.0.1:6379> GETBIT foo 6 (integer) 0 127.0.0.1:6379> GETBIT foo 7 (integer) 1
More: http://redis.io/commands/getbit, http://www.redis.cn/commands/getbit.html
GETRANGE key start end
Get a substring of the string stored at a key
127.0.0.1:6379> SET foo helloworld OK 127.0.0.1:6379> GETRANGE foo 0 3 "hell" 127.0.0.1:6379> GETRANGE foo 3 5 "low" 127.0.0.1:6379> GETRANGE foo 5 -1 "world"
More: http://redis.io/commands/getrange, http://www.redis.cn/commands/getrange.html
GETSET key value
Set the string value of a key and return its old value
127.0.0.1:6379> SET foo hello OK 127.0.0.1:6379> GETSET foo world "hello" 127.0.0.1:6379> GET foo "world"
More: http://redis.io/commands/getset, http://www.redis.cn/commands/getset.html
INCR key
Increment the integer value of a key by one
127.0.0.1:6379> SET foo 10 OK 127.0.0.1:6379> INCR foo (integer) 11 127.0.0.1:6379> INCR foo (integer) 12 127.0.0.1:6379> INCR bar (integer) 1
More: http://redis.io/commands/incr, http://www.redis.cn/commands/incr.html
INCRBY key increment
Increment the integer value of a key by the given amount
127.0.0.1:6379> SET foo 10 OK 127.0.0.1:6379> INCRBY foo 2 (integer) 12 127.0.0.1:6379> INCRBY foo 3 (integer) 15 127.0.0.1:6379> INCRBY bar 4 (integer) 4
More: http://redis.io/commands/incrby, http://www.redis.cn/commands/incrby.html
INCRBYFLOAT key increment
Increment the float value of a key by the given amount
127.0.0.1:6379> SET foo 10 OK 127.0.0.1:6379> INCRBYFLOAT foo 2.3 "12.3" 127.0.0.1:6379> INCRBYFLOAT foo 5.8E2 "592.29999999999999999" 127.0.0.1:6379> 127.0.0.1:6379> INCRBYFLOAT bar 3.33 "3.33"
More: http://redis.io/commands/incrbyfloat, http://www.redis.cn/commands/incrbyfloat.html
MGET key [key ...]
Get the values of all the given keys
127.0.0.1:6379> SET foo hello OK 127.0.0.1:6379> SET bar world OK 127.0.0.1:6379> MGET foo bar 1) "hello" 2) "world"
More: http://redis.io/commands/mget, http://www.redis.cn/commands/mget.html
MSET key value [key value ...]
Set multiple keys to multiple values
127.0.0.1:6379> MSET foo hello bar world OK 127.0.0.1:6379> MGET foo bar 1) "hello" 2) "world"
More: http://redis.io/commands/mset, http://www.redis.cn/commands/mset.html
MSETNX key value [key value ...]
Set multiple keys to multiple values, only if none of the keys exist
127.0.0.1:6379> SET foo hello OK 127.0.0.1:6379> MSETNX foo world bar world (integer) 0 127.0.0.1:6379> MGET foo bar 1) "hello" 2) (nil)
More: http://redis.io/commands/msetnx, http://www.redis.cn/commands/msetnx.html
PSETEX key milliseconds value
Set the value and expiration in milliseconds of a key
127.0.0.1:6379> PSETEX foo 10000 hello OK 127.0.0.1:6379> PTTL foo (integer) 8404 127.0.0.1:6379> GET foo "hello" 127.0.0.1:6379> PTTL foo (integer) -2 127.0.0.1:6379> GET foo (nil)
More: http://redis.io/commands/psetex, http://www.redis.cn/commands/psetex.html
SET key value [EX seconds] [PX milliseconds] [NX|XX]
Set the string value of a key
127.0.0.1:6379> SET foo hello OK 127.0.0.1:6379> GET foo "hello"
More: http://redis.io/commands/set, http://www.redis.cn/commands/set.html
SETBIT key offset value
Sets or clears the bit at offset in the string value stored at key
127.0.0.1:6379> SET foo a OK 127.0.0.1:6379> GETBIT foo 7 (integer) 1 127.0.0.1:6379> SETBIT foo 7 0 (integer) 1
More: http://redis.io/commands/setbit, http://www.redis.cn/commands/setbit.html
SETEX key seconds value
Set the value and expiration of a key
127.0.0.1:6379> SETEX foo 10 hello OK 127.0.0.1:6379> TTL foo (integer) 8 127.0.0.1:6379> GET foo "hello" 127.0.0.1:6379> TTL foo (integer) -2 127.0.0.1:6379> GET foo (nil)
More: http://redis.io/commands/setex, http://www.redis.cn/commands/setex.html
SETNX key value
Set the value of a key, only if the key does not exist
127.0.0.1:6379> SETNX foo hello (integer) 1 127.0.0.1:6379> GET foo "hello" 127.0.0.1:6379> SETNX foo world (integer) 0 127.0.0.1:6379> GET foo "hello"
More: http://redis.io/commands/setnx, http://www.redis.cn/commands/msetnx.html
SETRANGE key offset value
Overwrite part of a string at key starting at the specified offset
127.0.0.1:6379> SET foo helloworld OK 127.0.0.1:6379> SETRANGE foo 5 redis (integer) 10 127.0.0.1:6379> GET foo "helloredis"
More: http://redis.io/commands/setrange, http://www.redis.cn/commands/setrange.html
STRLEN key
Get the length of the value stored in a key
127.0.0.1:6379> set foo hello OK 127.0.0.1:6379> STRLEN foo (integer) 5
More: http://redis.io/commands/strlen, http://www.redis.cn/commands/strlen.html