Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@redis/json

Package Overview
Dependencies
Maintainers
3
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@redis/json

This package provides support for the [RedisJSON](https://redis.io/docs/stack/json/) module, which adds JSON as a native data type to Redis. It extends the [Node Redis client](https://github.com/redis/node-redis) to include functions for each of the Redi

  • 1.0.7
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2.2M
decreased by-1.94%
Maintainers
3
Weekly downloads
 
Created

What is @redis/json?

@redis/json is an npm package that provides a client for Redis' JSON capabilities, allowing you to store, retrieve, and manipulate JSON documents directly within Redis. This package leverages the RedisJSON module, which is designed to handle JSON data efficiently.

What are @redis/json's main functionalities?

Set JSON Data

This feature allows you to set JSON data in a Redis key. The code sample demonstrates how to connect to a Redis client, set a JSON object under a specific key, and then disconnect from the client.

const { createClient } = require('@redis/json');

async function setJsonData() {
  const client = createClient();
  await client.connect();
  await client.json.set('user:1', '$', { name: 'John Doe', age: 30, city: 'New York' });
  await client.disconnect();
}

setJsonData();

Get JSON Data

This feature allows you to retrieve JSON data from a Redis key. The code sample shows how to connect to a Redis client, get the JSON object stored under a specific key, log the data, and then disconnect from the client.

const { createClient } = require('@redis/json');

async function getJsonData() {
  const client = createClient();
  await client.connect();
  const userData = await client.json.get('user:1');
  console.log(userData);
  await client.disconnect();
}

getJsonData();

Update JSON Data

This feature allows you to update specific fields within a JSON object stored in Redis. The code sample demonstrates how to connect to a Redis client, update the 'age' field of the JSON object under a specific key, and then disconnect from the client.

const { createClient } = require('@redis/json');

async function updateJsonData() {
  const client = createClient();
  await client.connect();
  await client.json.set('user:1', '$.age', 31);
  await client.disconnect();
}

updateJsonData();

Delete JSON Data

This feature allows you to delete JSON data from a Redis key. The code sample shows how to connect to a Redis client, delete the JSON object stored under a specific key, and then disconnect from the client.

const { createClient } = require('@redis/json');

async function deleteJsonData() {
  const client = createClient();
  await client.connect();
  await client.json.del('user:1');
  await client.disconnect();
}

deleteJsonData();

Other packages similar to @redis/json

Keywords

FAQs

Package last updated on 29 Jul 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc