I am going to use Redis to store json documents that will have nested structure. My requirement is just to set and get the documents. I have no need to perform any json specific commands on the documents. Do I get any advantage by using rejson module. GET and SET commands will perform better than JSON.GET and JSON.SET commands. Following is from the redis documentation
JSON.SET Available since 1.0.0. Time complexity: O(M+N), where M is the size of the original value (if it exists) and N is the size of the new value.
JSON.GET Available since 1.0.0. Time complexity: O(N), where N is the size of the value.
GET key Available since 1.0.0. Time complexity: O(1)
SET key value [expiration EX seconds|PX milliseconds] [NX|XX] Available since 1.0.0. Time complexity: O(1)
Just want to confirm that storing the documents as string values is the right thing to do.
You can store JSON in redis either as a plain string in dedicated key (or member/value of a set/list) or in a hash structure. If you look at node_redis docs into Friendlier hash commands part you'll see that it gives you some useful methods for manipulating JSON based data.
RedisJSON stores the data in a binary format which removes the storage overhead from JSON, provides quicker access to elements without de-/re-serialization times. To use RedisJSON you need to install it in your Redis server or enable it in your Redis Enterprise database.
Paths help you access specific elements within a JSON document. Since no standard for JSON path syntax exists, RedisJSON implements its own. RedisJSON's syntax is based on common best practices and intentionally resembles JSONPath.
What is Redis? Redis, which stands for Remote Dictionary Server, is a fast, open source, in-memory, key-value data store. The project started when Salvatore Sanfilippo, the original developer of Redis, wanted to improve the scalability of his Italian startup.
If you really don't need to query on your JSON values directly than storing JSON as raw strings will be cheaper to access as there will be no JSON parsing on read/write.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With