Redis的核心數(shù)據(jù)類型:
- 字符串
set key value ---> 添加鍵值對
get key ---> 通過鍵查看值
strlen key ---> 獲取字符串長度
append key value2 ---> 給字符串追加內(nèi)容
mset key1 value1 key2 value2 ---> 添加多組鍵值對
mget key1 key2 ---> 查看多個鍵對應的值
incr key ---> 值加1
incrby key value ---> 值加上value
decr key ---> 值減1
decrby key value ---> 值減去value
getrange key start end ---> 獲取字符串指定范圍的子串
setrange key offset value ---> 修改字符串指定位置的內(nèi)容 - 哈希(表) - hash
hset key field value ---> 添加hash類型鍵值對
hmset key field1 value1 field2 value2 ---> 添加多組hash類型鍵值對
hget key field ---> 獲取hash類型字段對應的值
hmget key field1 field2 ---> 獲取hash類型多個字段對應的值
hgetall key ---> 獲取hash類型所有的字段和對應的值
hkeys key ---> 獲取hash類型所有的字段
hvals key ---> 獲取hash類型所有字段的值
hexists key field ---> 判斷hash類型某個字段是否存在 - 列表 - list
lpush key value1 value2 value3 ---> 在左邊添加元素
rpush key value1 value2 value3 ---> 在右邊添加元素
lpop key ---> 從左邊移除一個元素
rpop key ---> 從右邊移除一個元素
lrange key start end ---> 查看列表指定范圍的元素
llen key ---> 查看列表元素個數(shù)
lindex key index ---> 查看列表指定位置元素
lrem key count value ---> 刪除列表中指定元素 - 集合 - set
sadd key value1 value2 value3 ---> 添加元素
srem key value ---> 刪除元素
spop ---> 獲取隨機元素
scard key ---> 查看元素個數(shù)
smembers key ---> 查看所有元素
sismember key value ---> 查看集合中有沒有指定元素
sinter key1 key2 ---> 交集
sunion key1 key2 ---> 并集
sdiff key1 key2 ---> 差集 - 有序集合 - zset
zadd key score1 mem1 score2 mem2 ---> 添加元素
zrem key mem ---> 刪除元素
zrange key start end ---> 按score的升序查看元素
zrevrange key start end ---> 按score的降序查看元素
zscore key mem ---> 查看元素對應的score
zincrby key value mem ---> 修改元素的score值
LBS應用 - Location-Based Service - 基于位置的服務
Linux系統(tǒng)啟停服務
~ 啟動:systemctl start nginx
service nginx start
~ 停止:systemctl stop nginx
service nginx stop
~ 重啟:systemctl restart nginx
~ 查看狀態(tài):systemctl status nginx
~ 開機自啟:systemctl enable nginx
~ 禁用自啟:systemctl disable nginx