-
Notifications
You must be signed in to change notification settings - Fork 2
Collections
I have done a direct implementation on Redis of basic Java collections; of List, Map and Set interfaces.
Each one links to the same type on redis, and all the operations on the collection are donde directly and synchronously to Redis.
No data is stored in Java process (if possible), only on Redis.
The three jedis-backed collections follow strictly the Java interfaces contract and method (but no more) and can be used as regular collections in Java. There are only two points that musrt be taken in account:
- As jedis-backed collections, there is a little but non-negligible access time
- Many processes and threads can access the same collection, this can be desired in your code but sometimes must be taken into account. For example with iterators and loops - make sure an iteration isn't happenning at the same time of an insertion/removal in the same collection
You can download the collection data in any moment to Java memory (in JedisList is with asList method)
Also you can check if a collection exists in Jedis with exists() and checkExists() method. Take in account that redis auto-deletes empty collections on the server, so an empty one (method isEmpty() or size() return zero) is nowhere in redis.