redis中获取区间数据及获取总条数
2022/4/18 19:12:39
本文主要是介绍redis中获取区间数据及获取总条数,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
import redis REDIS_ITEMS_HOST: str = host REDIS_ITEMS_PASSWORD: str = pwd REDIS_ITEMS_DB: int = 4 #查询DB4 REDIS_ITEMS_PORT: int = 6379 new_r = redis.Redis(host=REDIS_ITEMS_HOST, password=REDIS_ITEMS_PASSWORD, port=REDIS_ITEMS_PORT, db=REDIS_ITEMS_DB) new_key = 'XXX' # redis key old_key = 'XXX' new_r_list = new_r.zrangebyscore(new_key, start, end) new_r_data = [info.decode('utf-8') for info in new_r_list] old_r_list = old_r.zrangebyscore(old_key, start, end) old_r_data = [info.decode('utf-8') for info in old_r_list]
#end = datetime.datetime.now().timestamp() * 1000
#start = int((datetime.datetime.now() - datetime.timedelta(days=3)).timestamp() * 1000)
end = 1650268800000 start = 1650267600000 print("条数:",new_r.zcount(new_key, start, end)) #比较两个redis的差异 print('旧存在,新不存在',set(old_r_data).difference(set(new_r_data)))
这篇关于redis中获取区间数据及获取总条数的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-12-24Redis资料:新手入门快速指南
- 2024-12-24Redis资料:新手入门教程与实践指南
- 2024-12-24Redis资料:新手入门教程与实践指南
- 2024-12-07Redis高并发入门详解
- 2024-12-07Redis缓存入门:新手必读指南
- 2024-12-07Redis缓存入门:新手必读教程
- 2024-12-07Redis入门:新手必备的简单教程
- 2024-12-07Redis入门:新手必读的简单教程
- 2024-12-06Redis入门教程:从安装到基本操作
- 2024-12-06Redis缓存入门教程:轻松掌握缓存技巧