3 min read

Introducing Upstash JSON for Redis®

Enes Akar

Cofounder @Upstash

What is RedisJSON?
Why is it important?
Example with and without RedisJSON
Legal Note
Closing Notes

I am excited to announce the JSON support in Upstash for Redis®. This means Upstash is compatible RedisJSON API. You can leverage RedisJSON API using these client libraries as well as Upstash SDK for Redis.

What is RedisJSON?

RedisJSON is a Redis® module that implements the standard specification for JSON, in Redis. It provides Redis® with native JSON data storage, manipulation, and processing capabilities, allowing developers to store, retrieve, and manipulate JSON data in Redis® using Redis® commands. With RedisJSON, developers can use Redis® as a complete solution for working with JSON data, eliminating the need to use additional data storage technologies for this purpose.

Why is it important?

RedisJSON is important because it provides native JSON support, which allows developers to work with JSON data in Redis® in a more efficient and convenient way. Prior to RedisJSON, working with JSON data in Redis® involved serializing and deserializing JSON data, which added overhead and complexity to the process.

With RedisJSON, developers can process the JSON data in Redis® using Redis® commands, just like they would with any other type of data in Redis. This eliminates the need for serialization and deserialization, making the process of working with JSON data in Redis® faster and more efficient.

In addition, RedisJSON provides a number of advanced features for working with JSON data, and perform operations on arrays and objects, and more. These features make RedisJSON a valuable tool for developers looking to store, process, and manipulate JSON data in Redis.

Example with and without RedisJSON

We will write a simple example where we update a field in a JSON object with and without RedisJSON

Without RedisJSON

// myjson -> { name: "John", age: 30 }

let myjson = await client.get("myjson");
myjson.age = 40;

await redis.set("myjson", myjson);

Cost of the above code is 2 Redis® calls + 1 serialization + 1 deserialization. Moreover, the operation is not atomic unless you run it on a script.

With RedisJSON

await client.json.set('myjson', '$.age', 30);

Cost of the above code is a single Redis® call. You do not worry about atomicity as it is a single operation.

Well, yes, we know RedisJSON is under the license of Redis® Ltd which is RSAL2/SSPL. Upstash did not use or copy any portion of RedisJSON. We implemented it from scratch, compatible with the API. Indeed, even their license was non-restrictive, we would still prefer to implement it ourselves 😎.

Closing Notes

We believe the integration of RedisJSON into Upstash expands the potential for various use cases and solidifies Redis' position as a leading data storage solution.. We continue to improve and develop Upstash guided by your feedback. Let us know your thoughts on Twitter or Discord.

© 2023 Upstash, Inc. Based in California.

* Redis is a trademark of Redis Ltd. Any rights therein are reserved to Redis Ltd. Any use by Upstash is for referential purposes only and does not indicate any sponsorship, endorsement or affiliation between Redis and Upstash.

** Cloudflare, the Cloudflare logo, and Cloudflare Workers are trademarks and/or registered trademarks of Cloudflare, Inc. in the United States and other jurisdictions.