Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Redis rejson or string

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.

like image 766
pawinder gupta Avatar asked Dec 05 '18 01:12

pawinder gupta


People also ask

How would you efficiently store JSON in Redis?

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.

Can we store JSON data in Redis?

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.

What is path in Redis JSON?

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 Rediss?

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.


1 Answers

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.

like image 167
Cody Caughlan Avatar answered Nov 06 '22 14:11

Cody Caughlan