簡體   English   中英

按值zset查找redis密鑰-Laravel

[英]find redis key by value zset - laravel

我在Redis中有zset,如下所示。

Type:zset
TTL:does not expire [E]
Encoding:ziplist



Score                    Value
 1                     0358899056725255

13                    {"voltage_level":"06","signal_strength":"02"}

我在每個連接上都有一個具有動態ip的設備,具有唯一值(此處為0358899056725255)。 每當設備重啟時,其IP將被更改,因此我需要創建一個新的zset。 我想為此特定值刪除所有舊的垃圾IP。

我的想法

Redis::zadd($conn->remoteAddress, '01', $imei); //to add new ip
//scan all ip and check one by one 
@start loop
$val=Redis::zrangebyscore($ip[$i], 01, 01);
if($val=='0358899056725255')
  Redis::del($conn->remoteAddress);
@end loop

我有超過10,000台設備,但我不想重復使用,是否有一些簡單的解決方案

我想到了

 Keep the expiry date on redis, which will be auto expired 
 Redis::zadd($conn->remoteAddress, '01', $imei); //to add new ip
 Redis::expire($conn->remoteAddress, (60*60*24*30));

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM