Back to results for “JSON”
Redis › RedisJSON

How would you design a document based data model using RedisJSON for an application that would traditionally use a document database like MongoDB?

Advanced

Answer

You would structure your data as nested JSON documents that closely match how your application naturally thinks about its entities, use RedisJSON's path based commands to efficiently update specific fields without rewriting entire documents, combine it with RedisSearch if you need rich querying capabilities across document fields, and take advantage of Redis's overall speed for read heavy access patterns.
JSON.SET order:1001 $ '{"customerId":123,"items":[{"product":"laptop","qty":1}],"status":"pending"}'
Real-world example A team building a fast order management system uses RedisJSON to store complete order documents with nested item arrays, taking advantage of Redis's speed for their read heavy dashboard while still working with a natural, document oriented data model.

Common follow-ups: What are the tradeoffs of using RedisJSON versus a dedicated document database for this kind of application?;How does RedisJSON handle very deeply nested or very large documents?