is redisJSON better than plain redis when keeping data for boardgame session data? is redisJSON better than plain redis when keeping data for boardgame session data? express express

is redisJSON better than plain redis when keeping data for boardgame session data?


The answer is it depends and it requires several trade-offs to be made for each project

  • Performance: RedisJSON uses a tree structure for storing all elements in a document.
    • Comparing to a string: the advantage is that updating sub-elements of a document will be faster than manipulating a string containing a serialised JSON object. But retrieving (reassembling) and writing the entire document will be more expensive compared to Strings. Read more here.
    • Comparing to Hash: when manipulating a flat document (1 level deep), RedisJSON and HSET performance are comparable.
  • Maintainability: using several native data types in Redis to represent your object can be really performing, but the code will be more complex to maintain. There can be additional migration/refactoring work when the structure of the document is altered.
  • Querying: RediSearch will soon add support for indexing and querying the content RedisJSON documents. This is, of course, if your use case requires secondary indexing and querying documents other than with their key. You can still build your own secondary indexing with Redis data structures, but this is also a trade-off in maintainability

disclaimer: I work for RedisLabs, creator and maintainer of RediSearch and RedisJSON