2

I've recently discovered that redis has a property graph model implementation called redis graph and it's amazing.

One thing that I really miss for my use-case though, is the ability to "watch" the data. In typical redis data structures I can enable Keyspace notifications or client tracking and be notified on the data mutations I'm interested in, pull data from the server or mark my local cache as "dirty".

I don't know how that would work for a property graph since relations are much more complex (and the key feature for that matter), but is there a way to watch or synchronize with data stored in redis graph?

Lorah Attkins
  • 5,331
  • 3
  • 29
  • 63

2 Answers2

1

No. Unfortunately, currently, there is no way to trigger a keyspace notification whenever nodes or relationships are created, removed, or updated.

We plan to add such functionality in the future, but there is no specific date we can share right now.

Lior Kogan
  • 19,919
  • 6
  • 53
  • 85
  • Not even with `CLIENT TRACKING ON`? I thought I could `SUBSCIRBE __redis__:invalidate`. Is there a roadmap or a github discussion / project where one can contribute ? – Lorah Attkins Nov 29 '22 at 17:29
  • 1
    Note that an entire graph is stored under a single Redis key, so invalidation would be for the entire graph, not for a single node or relationship which is not what we want to achieve. [The following issue](https://github.com/RedisGraph/RedisGraph/issues/1228) is similar to your question. We'll update there of course. – Lior Kogan Nov 29 '22 at 17:37
  • 2
    Please keep up the good work, redis.graph can be solution to a tremendous range of cases, especially if mutations are "watchable". I've done something similar in a module where (lacking better options) I'd atomically publish a message in a dedicated channel, e.g. `GRAPH:nameofgraph` and the contents of the message where the name/id of the modified entities, e.g. `node:2245` or `edge:5528`. So a "watcher" could pull updates if something of interest happened. Of course this lacks the granularity of typical redis solutions and you probably already know your alternatives. Just thinking out loud – Lorah Attkins Nov 29 '22 at 17:45
1

Keyspace notifications can be enabled for modules like this:

redis.cloud> CONFIG SET notify-keyspace-events AKE

The 'A' part includes modules—if the module publishes anything. Unfortunately, I tried this with RedisGraph, and it doesn't.

You can reproduce my test below. In one terminal I launched redis-cli and did this:

127.0.0.1:6379> PSUBSCRIBE *
Reading messages... (press Ctrl-C to quit)
1) "psubscribe"
2) "*"
3) (integer) 1

In another I did this:

127.0.0.1:6379> GRAPH.QUERY test 'CREATE (n:foo { alfa: 12, bravo: "test" })'
1) 1) "Labels added: 1"
   2) "Nodes created: 1"
   3) "Properties set: 2"
   4) "Cached execution: 0"
   5) "Query internal execution time: 0.204701 milliseconds"
127.0.0.1:6379> GRAPH.QUERY test 'MATCH (n) RETURN n'
1) 1) "n"
2) 1) 1) 1) 1) "id"
            2) (integer) 0
         2) 1) "labels"
            2) 1) "foo"
         3) 1) "properties"
            2) 1) 1) "alfa"
                  2) (integer) 12
               2) 1) "bravo"
                  2) "test"
3) 1) "Cached execution: 0"
   2) "Query internal execution time: 1.106191 milliseconds"
127.0.0.1:6379> GRAPH..DELETE test
"Graph removed, internal execution time: 0.064498 milliseconds"

The first terminal returned nothing in response to this.

Guy Royse
  • 2,739
  • 12
  • 9
  • 1
    Deleted the previous comment. Just saw you're deeply involved in redis development as well. Thank you for providing a succinct method to test this. (the previous comment confirmed your post by quoting the other answer from a PM at Redis - probably you work together albeit in different projects) – Lorah Attkins Nov 29 '22 at 17:47
  • 1
    Happy to help. I'm a developer advocate so I mostly just promote and support stuff other people develop. But I *use* the stuff a lot! ;) RedisGraph is probably my favorite module. – Guy Royse Nov 30 '22 at 15:38