众所周知,Redis是有个keys的命令查询所有key的,当然现网不建议这么玩儿。
那上古缓存服务memcache有类似的指令吗?业务上碰到一个需要人工校验定位问题的场景,需要用类似的指令,搜了下,方法如下:
-
stats items
得到所有的数据,例如:
STAT items:2:number 322319
STAT items:2:age 172801
STAT items:2:evicted 0
STAT items:2:evicted_nonzero 0
STAT items:2:evicted_time 0
STAT items:2:outofmemory 0
STAT items:2:tailrepairs 0
STAT items:2:reclaimed 2278852
STAT items:2:expired_unfetched 2278852
STAT items:2:evicted_unfetched 0
STAT items:2:crawler_reclaimed 0
STAT items:2:crawler_items_checked 0
STAT items:2:lrutail_reflocked 0
STAT items:3:number 2
STAT items:3:age 4167
STAT items:3:evicted 0
STAT items:3:evicted_nonzero 0
STAT items:3:evicted_time 0
STAT items:3:outofmemory 0
STAT items:3:tailrepairs 0
STAT items:3:reclaimed 9
STAT items:3:expired_unfetched 7
STAT items:3:evicted_unfetched 0
STAT items:3:crawler_reclaimed 0
STAT items:3:crawler_items_checked 0
STAT items:3:lrutail_reflocked 0
STAT items:4:number 31
STAT items:4:age 93448
STAT items:4:evicted 0
STAT items:4:evicted_nonzero 0
STAT items:4:evicted_time 0
STAT items:4:outofmemory 0
STAT items:4:tailrepairs 0
STAT items:4:reclaimed 5
STAT items:4:expired_unfetched 5
STAT items:4:evicted_unfetched 0
STAT items:4:crawler_reclaimed 0
STAT items:4:crawler_items_checked 0
STAT items:4:lrutail_reflocked 0 - 假设要查看(items:3:number 2),即items 3,包含2个元素的keys,则执行:
stats cachedump 3 2
得到类似输出:
stats cachedump 3 2
ITEM aa340_7q544xyrava3vxf [55 b; 1702627086 s]
ITEM aa340_3096861525888001 [51 b; 1702627086 s]
END - 上面dump出来的
aa340_7q544xyrava3vxf
就是key,取值只需要直接get即可。
参考资料
如您从本文得到了有价值的信息或帮助,请考虑扫描文末二维码捐赠和鼓励。
如本文对您有用,捐赠和留言 将是对我最好的支持~(捐赠可转为站内积分)
如愿意,请向朋友推荐本站,谢谢。
尊重他人劳动成果。转载请务必附上原文链接,我将感激不尽。