I want to use redis's sets data structure to store user's followers list, How I can do paging to fetch records from list based on page size?
How to do paging on redis's sets data structure?
1.3k Views Asked by Suyog Kale At
2
There are 2 best solutions below
0
Didier Spezia
On
You can try to leverage the SSCAN command. Make sure to understand how the SCAN command works first.
Related Questions in CACHING
- ClassCastException: datastructures.instances.JClass cannot be cast to java.util.ArrayList
- Robospice. How to save data and how to get data from DB?
- Make @lru_cache ignore some of the function arguments
- Xib taking long time (>1s) to load. UIFont cache seems to blame
- Android picasso cache images
- Rails 4 low-level caching not working
- How to cache Exchange web service API autodiscoverurl?
- The process cannot access the file because it is being used by another process asp.net
- Alamofire loading from cache even when cache policy set to ReloadIgnoringLocalAndRemoteCacheData
- Java Heap vs Cache
- In what use cases is locking on ASP.NET cache required/desirable
- Chrome cache overriding angularjs disabling of cache
- AFNetworking 2.0 Cache Issue
- Symfony ESI Cache / Surrogate Listener Issue
- Using getOrElseUpdate of TrieMap in Scala
Related Questions in REDIS
- start redis with supervisor
- How to do Mass insertion in Redis using JAVA?
- RedisResponseException: Unknown reply on multi-request
- Redis / Get all keys & values from redis with prefix
- Remove a member from multiple sets in Redis
- Using memcached or Redis on aws-elasticache
- Get Socket Object by Id with node, redis-adapter and socket.io
- how can i save a complex json as string in redis and retrieve it as unescaped legit json object
- How to specify versions on PIP when installing a python package with it's dependencies
- Eloquent model for Redis
- Is exists check required before calling StringSet method of StrackExchange.Redis
- Predis: Pros and Cons of the two cluster strategies
- hmset redis with result from mysqlDB
- does redis cluster support transactions ?
- How change redis to be persistent
Related Questions in SET
- Removing duplicates from arraylist using set
- Order-independent Hash Algorithm
- How to count 2 different duplicate values in array - Swift
- CMD specifying columns to save?
- comparison of two sets when repeated in r
- How to use set(data structure) in mongodb console?
- Reversing logic of a product-country mapping
- Storing data in sorted manner in a HashSet
- Generate all combinations of strings and their substrings in a set -- python
- How to access class data in a set of pointers to that class
- Scala set element uniqueness: What to implement for comparison of user defined classes?
- java.util.Set add and remove method signature difference
- retrieve all the smallest strings from a set in python
- Setting a String Variable in SSIS
- Setting a robocopy log file to a variable
Related Questions in PAGING
- Paging data tables in jQuery
- datastax 4.7 The 'start' parameter is not allowed in c# driver with autopaging off
- URL not working ASP MVC in SMS function
- Horizontal Swipe in an activity
- Paging in .NET Web API
- How to hide DIV in paging
- On heap/stack and OS page swapping
- No result when Pagination with Servlet and JSP
- jqgrid paging on server side
- How can I do paging and sorting using spring data with Couchbase
- Using Paging Query Attribute in .NET Web API
- On x86, does enabling paging cause an "unconditional jump" (since EIP is now a virtual address)?
- Locally paging on Extjs 5 store of type ajax
- KendoUI Scheduler Page Events by Time
- Is there any way to add pagination to a table, which fetches data from database?
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
On top of what @Didier Spezia wrote, I'd also try to store the followers in a sorted set.
If you want them by name, store them all with score of 0, and then use ZRANGEBYLEX to page them lexically.
If you want by the order that they were added as friends, use the timestamp of addition as the score, and use ZRANGE to page them by time.
[EDIT] oh, another option to look at if memory concerns you: if the ids are constant length integers, you can store them as binary values in an array using a string key, and page it with ranges. It will be super fast and will have virtually 0 memory overhead. Have a look at the BITFIELD command. It might be a very good use case for it, although it doesn't cover deletion and lookup, so if those are a concern it's not a good option.