Redis in Action
Redis
REmote DIctionary Server(Redis)
Redis 是一種開放源代碼(BSD許可)的內存中數據結構存儲,用作數據庫,緩存和消息代理。
它支持數據結構,例如字符串,哈希,列表,集合,帶范圍查詢的排序集,位圖,超級日志,帶有半徑查詢和流的地理空間索引。
# redis-server version
$ redis-server -v
$ redis-server --version
# Redis server v=6.0.6 sha=00000000:0 malloc=libc bits=64 build=5b8f79637e2b0790
# redis-client version
$ redis-cli -v
$ redis-cli --version
# redis-cli 6.0.6
# If you want to know the version of the server, from the client
> INFO
https://stackoverflow.com/questions/22153504/how-to-find-out-redis-version
https://stackoverflow.com/questions/21555942/how-to-check-redis-instance-version
REPL
$ HELP
# Please type HELP for one of these commands: DECR, DECRBY, DEL, EXISTS, EXPIRE, GET, GETSET, HDEL, HEXISTS, HGET, HGETALL, HINCRBY, HKEYS, HLEN, HMGET, HMSET, HSET, HVALS, INCR, INCRBY, KEYS, LINDEX, LLEN, LPOP, LPUSH, LRANGE, LREM, LSET, LTRIM, MGET, MSET, MSETNX, MULTI, PEXPIRE, RENAME, RENAMENX, RPOP, RPOPLPUSH, RPUSH, SADD, SCARD, SDIFF, SDIFFSTORE, SET, SETEX, SETNX, SINTER, SINTERSTORE, SISMEMBER, SMEMBERS, SMOVE, SORT, SPOP, SRANDMEMBER, SREM, SUNION, SUNIONSTORE, TTL, TYPE, ZADD, ZCARD, ZCOUNT, ZINCRBY, ZRANGE, ZRANGEBYSCORE, ZRANK, ZREM, ZREMRANGEBYSCORE, ZREVRANGE, ZSCORE
$ help SET
# OR
$ help set
"""
SET key value
TIME COMPLEXITY: O(1)
DESCRIPTION: Set key to hold the string value. If key already holds a value, it is overwritten, regardless of its type. Any previous time to live associated with the key is discarded on successful SET operation.
Options
EX seconds -- Set the specified expire time, in seconds.
PX milliseconds -- Set the specified expire time, in milliseconds.
NX -- Only set the key if it does not already exist.
XX -- Only set the key if it already exist.
RETURN VALUE: Status code reply: OK if SET was executed correctly. Null multi-bulk reply: a Null Bulk Reply is returned if the SET operation was not performed because the user specified the NX or XX option but the condition was not met.
"""
# use the command SET to store the value "fido" at key "server:name":
SET server:name "fido"
# OK
# use the command GET to read the value stored at key server:name
GET server:name
# "fido"
# test if a give key exists(1) or not(0)
EXISTS server:name
# (integer) 1
EXISTS server:blabla
# (integer) 0
docs
https://redis.io/documentation
數據結構
String: 字符串
Hash: 散列
List: 列表
Set: 集合
Sorted Set: 有序集合
bitmaps
hyperloglogs
geospatial indexes
Ctrl + ⬇
切換 vscode workspace
refs
http://download.redis.io/releases/redis-6.0.6.tar.gz
©xgqfrms 2012-2020
www.cnblogs.com 發布文章使用:只允許注冊用戶才可以訪問!