using redis for tree data structure

374 views
Skip to first unread message

Matan Levy

unread,
Apr 24, 2018, 1:43:28 AM4/24/18
to Redis DB
Hi,

I need to develop a cache system for tree based key-value (very similar to windows registry).

in that cache, keys are strings which represents path in the tree to the value,which can be primitive type(int,string,bool,double etc.) or subtree by it self.

for example :


key = root\x\y\z\w , value = the whole subtree under w

key = root\x\y\z\w\t , value = integer 


I thought about using Redis as simple cache implemntation, but naive key-value will miss the point of tree hierarchy.

in addition, in this naive way , guessing I have in cache already


key = root\x\y, value = the whole subtree under y


and i am looking for


key = root\x\y\z


the naive key-value won't find it although it is already exist in cache.


the best data strucutre which I can think about is a prefix-tree (Trie) which can handle the keys in more efficient way and can easily find cases of sub-string as I mentioned above.


I could not find any implmentation of Redis which can handle this data strcutre yet, but I am still new to all those implementations.


Can Redis handle this kind of cache?or should I find an alternative way?

Itamar Haber

unread,
May 3, 2018, 8:15:49 AM5/3/18
to Redis DB
Hello Matan,

Redis doesn't do trees (yet). If you must have a tree-like structure stored in Redis, I recommend you look at http://rejson.io.

Alternatively, you can develop a Redis module that does anything you want/need.

Disclaimer: I am one of ReJSON's authors.

Cheers,

--
You received this message because you are subscribed to the Google Groups "Redis DB" group.
To unsubscribe from this group and stop receiving emails from it, send an email to redis-db+unsubscribe@googlegroups.com.
To post to this group, send email to redi...@googlegroups.com.
Visit this group at https://groups.google.com/group/redis-db.
For more options, visit https://groups.google.com/d/optout.



--

Itamar Haber | Technology Evangelist
Redis Labs ~/redis

Mobile: +972 (54) 567 9692
Twitter: @itamarhaber
Skype: itamar.haber

Reply all
Reply to author
Forward
0 new messages