I'm trying to store nodes of a graph in redis. My node is of type HashMap(String fromNode, HashMap(String toNode,Integer weight) ) How do I store such data structure in redis?
Asked
Active
Viewed 301 times
2 Answers
2
If you're just interested in storing the data, any serialization to a String would do. If you want to query the data, first define the queries and then choose the data structure.
Intuitively, without familiarity with your requirements, I'd use a Sorted Set per fromNode, in which each member is a toNode and the score is set to its weight. That said, a graph implementation is far from trivial. As an alternative, check Redis Graph
- a Redis v4 module that implements a graph database with a Cypher-like querying language.

Itamar Haber
- 47,336
- 7
- 91
- 117
-
I'm trying to build redis-graph from https://github.com/swilly22/redis-graph using command: cmake . && make module, but I get error : 3 warnings generated. [ 95%] Building C object CMakeFiles/module.dir/rmutil/util.o [ 97%] Building C object CMakeFiles/module.dir/rmutil/strings.o [100%] Linking C shared module libmodule.so – gaurav1207 May 15 '17 at 21:19
-
Please make an issue report at the repository – Itamar Haber May 15 '17 at 22:38
-
This appears to be yours too :) http://stackoverflow.com/questions/43988661/error-when-building-redis-graph – Itamar Haber May 15 '17 at 23:47
1
At the moment RedisGraph requires UUID, please make sure UUID lib is installed on your system, to install run: apt-get install uuid-dev
Please let me know if resolved, Thank you.

SWilly22
- 869
- 4
- 5
-
I have added my comment on repo, After installing apt-get install uuid-dev and then cmake ., when I try to run redis-server --loadmodule
/src/libmodule.so I get following error *** FATAL CONFIG FILE ERROR *** Reading the configuration file, at line 2 >>> 'loadmodule "/ – gaurav1207 May 16 '17 at 10:05/redis-graph/src/libmodule.so"' Bad directive or wrong number of arguments -
So following configuration worked for me : 1. updated Redis server to v4 on Ubuntu 2. passed the complete path of redis-server when using --loadmodule flag. – gaurav1207 May 16 '17 at 11:29