Redis被稱為「資料結構伺服器」,因為其中的值(Value)可以是字串(String)、雜湊(Hash)、清單(List)、集合(Set)和有序集合(Sorted Set)等類型。
wget https://download.redis.io/release/redis-6.0.9.tar.gz
tar xzf redis-6.0.9.tar.gz
cd redis-6.0.9
make
src/redis-server
src/redis-cli
keys *
set your_key your_value
get your_key
//存在就修改原值;不存在就創建
set your_key your_new_value
//不修改原值
set your_key your_value NX
//在原值後面加字串
append key value
//數值加1
incr key
//數值減1
decr key
//數值加n
incrby key n
//數值減n
decrby key n
del key
hset key field value
hmset key field1 value1 [field2 value2 ]
hget key field
hmget key field
hgetall key
HEXISTS key field
hlen key
//從左邊插入
lpush key value
//從右邊插入
rpush key value
llen key
lrange key start_Index end_Index
//從左邊刪除
lpop key
//從右邊刪除
rpop key
sadd key value1 value2...
scard key
zadd key score1 member1 [score2 member2]
score型態必須是double。
zadd key NX score member
zrangebyscore key min max [WITHSCORES] [LIMIT offset count]
zrank key member
zscore key member
zcount key min max