Advertisement
Beginner Redis, RedisJSON

What is RedisJSON, and how does it improve working with JSON data compared to storing it as a plain string?

Short answer

RedisJSON is a module that adds native support for storing, retrieving, and modifying JSON documents directly within Redis, letting you access and update specific fields deep within a document without needing to retrieve, parse, modify, and rewrite the entire JSON string, which…

Save Redis mock interview
Advertisement
AModel answer
RedisJSON is a module that adds native support for storing, retrieving, and modifying JSON documents directly within Redis, letting you access and update specific fields deep within a document without needing to retrieve, parse, modify, and rewrite the entire JSON string, which is required when JSON is simply stored as a plain text value.
JSON.SET user:100 $ '{"name":"Sarah","age":29,"address":{"city":"Boston"}}'
JSON.GET user:100 $.address.city
Real-world example
A user profile system stores complete user documents as JSON using RedisJSON, letting the application directly update just a user's city field without needing to retrieve and rewrite the entire profile document.
Likely follow-ups
  • How much more efficient is this compared to storing JSON as a plain string?
  • What happens if you try to use JSON.SET on a key that already holds a non JSON value?
Related topics