幸运飞艇停吗

ASP源碼.NET源碼PHP源碼JSP源碼JAVA源碼DELPHI源碼PB源碼VC源碼VB源碼Android源碼
當前位置:首頁 >> 網頁制作 >> Javascript教程 >> redis5x新特性,Stream流數據類型使用簡單教程

redis5x新特性,Stream流數據類型使用簡單教程(1/2)

來源:網絡整理     時間:2018-10-25     關鍵詞:

BENPIANWENZHANGZHUYAOJIESHAOLE" redis5xXINTEXING,StreamLIUSHUJULEIXINGSHIYONGJIANDANJIAOCHENG",ZHUYAOSHEJIDAOFANGMIANDENEIRONG,DUIYUJavascriptJIAOCHENGGANXINGQUDETONGXUEKEYICANKAOYIXIA: SHISHISHANGRedisDESHUJULEIXINGYIZHIDOUSHIERJINZHIANQUANDE,JIHUMEIYIZHONGSHUJULEIXINGDOUSHIKEYIYONGLAICUNCHULIUDE。NEIWEISHENMERedis 5.0YAOYINYONGStreamSHUJULEIXINGNI? JUTIRUHESHIYONG?...

事實上Redis的數據類型一直都是二進制安全的,幾乎每一種數據類型都是可以用來存儲流的。那為什么Redis 5.0要引用Stream數據類型呢? 具體如何使用?

StreamSHISHENME

幸运飞艇停吗ZAIYIBANDEBIANCHENGGAINIANLI,LIUSHIYIZHONGZHUYAOYONGYUYOUHUANEICUNDESHUJULEIXING,TABUXUYAOYICIXINGBADALIANGSHUJU,BIRUSHUODAWENJIANYICIXINGDUQUDAONEICUNZAICHULI,KEYIBIANDUQUBIANCHULI,ZHEYANGKEYIYONGSHAOLIANGNEICUNJIUKEYICHULIDAWENJIAN。

YINCIJIANDANDISHUO,LIUSHIRedisYIZHONGXINDESHUJUJIEGOU,BUXUYAODUQUYUANYOUkeyDEZHI,JIUKEYIZAICIkeyZHONGTIANJIAXINNEIRONGDESHUJULEIXING。

StreamTIANJIA

幸运飞艇停吗StreamKEYIYONGGENGCHOUXIANGDEFANGSHILAIJILUSHUJU,BIRUSHUORIZHI。

幸运飞艇停吗StreamLEIXINGCUNCHUDEBUSHIYIGEZIFUCHUAN,ERSHIDUOGEJIANZHIDUI,BIRU:

XADD mystream * sensor-id 1234 temperature 19.8
> 1518951480106-0

幸运飞艇停吗DAIBIAOWANGmystreamTIANJIAXINDESHUJU { "sensor-id": 1234, "temperature": 19.8 }, *DAIBIAOFUWUQIDUANSHENGCHENGYIGEXINDEEntryID

1518951480106-0 是代表這組數據的EntryID值,可以理解為日志中的行號。1518951480106是當前時間的毫秒值,0代表這一時侯的第幾個數據。可以用XLEN查看總數據個數。

> XLEN mystream
(integer) 1

幸运飞艇停吗YEKEYIZIJIZHIDINGEntryIDDEZHI,RU:

> XADD somestream 0-1 field value
0-1
> XADD somestream 0-2 foo bar
0-2

幸运飞艇停吗LIUSHIZHIZENGBUJIANDE,SUOYIRUGUOentryidZHIBIZHIQIANDEXIAO,ZEHUIBAOCUO:

> XADD somestream 0-1 foo bar
(error) ERR The ID specified in XADD is equal or smaller than the target stream top item

StreamCHAXUN

幸运飞艇停吗KEYIYONG XRANGE/XREVRANGE LAICHAZHAO,- + DAIBIAOCHAZHAOSUOYOUDE。

> XRANGE mystream - +
1) 1) 1518951480106-0
   2) 1) "sensor-id"
      2) "1234"
      3) "temperature"
      4) "19.8"
2) 1) 1518951482479-0
   2) 1) "sensor-id"
      2) "9999"
      3) "temperature"
      4) "18.2"

幸运飞艇停吗KEYIZHIDINGEntryIDDEZHIFANWEI,KEYILIJIEWEIQUMOUGESHIJIANDUANDERIZHINEIRONG

> XRANGE mystream 1518951480106 1518951480107
1) 1) 1518951480106-0
   2) 1) "sensor-id"
      2) "1234"
      3) "temperature"
      4) "19.8"

可以只取前兩個

> XRANGE mystream - + COUNT 2
1) 1) 1519073278252-0
   2) 1) "foo"
      2) "value_1"
2) 1) 1519073279157-0
   2) 1) "foo"
      2) "value_2"

幸运飞艇停吗RedisLIUJIESHAO http://redis.io/topics/streams-intro

幸运飞艇停吗Redis 5.0DEZHUYAOGAIJIN:

相關圖片

相關文章