Redis擴展

Redis擴展

慢查詢

生命週期

Redis生命週期

兩個配置

默認值

config get slowlog-max-len = 128
config get slowlog-log-slower-than = 10000 # 慢查詢閾值,單位:微秒
  • showlog-log-slower-than = 0 :記錄所有命令
  • showlog-log-slower-than < 0 :不記錄任何命令

命令

  • slowlog get [n] :獲取慢查詢隊列
  • slowlog len :獲取慢查詢隊列長度
  • slowlog reset :清空慢查詢隊列

pipeline

pipeline

發佈訂閱

發佈訂閱模型

發佈訂閱模型

命令

  • publish channel message :發佈
  • subscribe [channel] :訂閱
  • unsubscribe [channel] :取消訂閱
  • psubscribe [pattern] :指定訂閱模式
  • punsubscribe [pattern] :退訂指定模式
  • pubsub channels :列出至少有一個訂閱者的頻道
  • pubsub numsub [channel...] :列出給定頻道的訂閱者數量
  • pubsub numpat :列出被訂閱模式的數量

消息隊列模型

消息隊列模型

Bitmap

命令

  • setbit key offset value :給位圖指定索引設置值
  • getbit key offset :獲取位圖指定索引的值
  • bitcount key [start end] :獲取位圖指定範圍值爲1的個數
  • bitop op destkey key [key...] :將多個Bitmap的and(交集)、or(並集)、not(非)、xor(異或)操作並將結果保存在destkey中
  • bitops key targetBit [start] [end] :計算位圖指定範圍第一個偏移量對應值等於targetBit的位置

HyperLogLog

利用極小的空間完成獨立數量的統計。

命令

  • pfadd key element [element ...] :向hyperloglog添加元素
  • pfcout key [key ...] :計算hyperloglog的獨立總數
  • pfmerge destkey sourcekey [sourcekey ...] :合併多個hyperloglog

GEO

GEO(地理信息定位):存儲經緯度,計算兩地距離,範圍計算

命令

geo add longitude latitude member :增加地理位置信息
geopos key member [member ...] :獲取地理位置信息
geodist key member1 member2 [unit] :獲取兩個地理位置的距離,unit:m(米)、km(千米)、mi(英里)、ft(尺)

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章