[英]find redis key by value zset - laravel
I have zset in redis like below. 我在Redis中有zset,如下所示。
Type:zset
TTL:does not expire [E]
Encoding:ziplist
Score Value
1 0358899056725255
13 {"voltage_level":"06","signal_strength":"02"}
I have one device with dynamic ip on each connection with unique value (0358899056725255 here). 我在每个连接上都有一个具有动态ip的设备,具有唯一值(此处为0358899056725255)。 When ever the device restart, its ip will be changed as a result i need to make a new zset .
每当设备重启时,其IP将被更改,因此我需要创建一个新的zset。 I want to delete all old garbage ip for this particular value.
我想为此特定值删除所有旧的垃圾IP。
What I treid 我的想法
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
I have like 10,000+ devices and I dont want to iterate, is there some easy solutions 我有超过10,000台设备,但我不想重复使用,是否有一些简单的解决方案
I figured it out 我想到了
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.