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-11-08阿里云Redis项目实战入门教程
- 2024-11-08阿里云Redis资料:新手入门与初级使用指南
- 2024-11-08阿里云Redis教程:新手入门及实用指南
- 2024-11-07阿里云Redis学习入门:新手必读指南
- 2024-11-07阿里云Redis学习入门:从零开始的操作指南
- 2024-11-07阿里云Redis学习:初学者指南
- 2024-11-06阿里云Redis入门教程:轻松搭建与使用指南
- 2024-11-02Redis项目实战:新手入门教程
- 2024-10-22Redis入门教程:轻松掌握数据存储与操作
- 2024-10-22Redis缓存入门教程:快速掌握Redis缓存基础知识