Redis哈希分页 [英] Redis Hash Pagination
问题描述
我正在使用 Redis Hash ,其中我将学生ID存储为键(非数字),值是学生数据的POJO.现在我需要重新分页,即我不在乎学生的顺序,但我只想一次性获取一些学生数据.我可以在Redis中做到这一点吗?如果要支持分页,还需要对数据结构进行一些修改,那也是可以的.
P.S.我正在使用 spring-data-redis .但是没有它的解决方案也可以.基本上,我想确定redis是否支持散列的分页.
听起来像您在寻找 SCAN
命令相同的界面,因此请查看示例.>
我对spring-data-redis
不熟悉,但是它可能对此功能有一些不错的包装.否则,请下拉至其运行的任何Redis库,然后直接执行.
I am using the Redis Hash, in which I am storing student id as the key (which is not numeric), the value is POJO of student data. now I need redis-pagination i.e. I don't care about the students' order but I want to fetch only some students data in one go. can I do this in Redis? if for supporting the pagination some modification in the data structure is required that would be ok too.
P.S. I am using spring-data-redis. but the solution without it would be ok too. basically, I want to find out whether redis supports pagination for hashes.
Sounds like you are looking for the HSCAN
command, which lets you page through a hash using a cursor. It has the same interface as the global key SCAN
command, so look there for examples.
I'm not familiar with spring-data-redis
but it might have some nice wrapper for this functionality. Otherwise, drop down to whatever redis library it runs on and execute it directly.
这篇关于Redis哈希分页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!