Search code examples
cachingluaredisin-memory-database

Which in memory Db should be used to cache a Tree, used majorly for read?


Use case: We have a Trie Data Structure which will be accessed over 100k times a day. Traverse this trie(based on input params) and return the JSON stored at leaf node.

Issue/Concern: Initially, I tried storing this Trie in Redis and perform the traversal logic using LUA script. However, while it executes, LUA script blocks the whole Redis server. Therefore, some times it hits performance of my system.

Question: I have two questions:

  1. What's the best strategy to cache this Trie in which reads are high, with rarely any updates.
  2. Is Redis, the best choice for this use case? If not, please suggest.

Solution

  • We are going ahead with using 'near cache' with Redis. Redisson provides this capability. If Redisson causes problems, we will try Hazelcast, which by default provides near cache.