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

@redis/client

Package Overview
Dependencies
Maintainers
3
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@redis/client

The source code and documentation for this package are in the main [node-redis](https://github.com/redis/node-redis) repo.

  • 1.6.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2.1M
decreased by-14.94%
Maintainers
3
Weekly downloads
 
Created

What is @redis/client?

@redis/client is a Node.js client for Redis, a powerful in-memory data structure store. This package allows you to interact with a Redis server to perform various operations such as setting and getting keys, managing data structures like lists and sets, and handling pub/sub messaging.

What are @redis/client's main functionalities?

Basic Key-Value Operations

This feature allows you to perform basic key-value operations such as setting and getting values from the Redis store.

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

(async () => {
  const client = createClient();
  await client.connect();

  await client.set('key', 'value');
  const value = await client.get('key');
  console.log(value); // Output: 'value'

  await client.disconnect();
})();

Data Structures

This feature allows you to manage complex data structures like lists. The example demonstrates how to push values to a list and retrieve them.

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

(async () => {
  const client = createClient();
  await client.connect();

  await client.lPush('list', 'value1');
  await client.lPush('list', 'value2');
  const list = await client.lRange('list', 0, -1);
  console.log(list); // Output: ['value2', 'value1']

  await client.disconnect();
})();

Pub/Sub Messaging

This feature allows you to use Redis's pub/sub messaging capabilities. The example shows how to publish a message to a channel and subscribe to that channel to receive messages.

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

(async () => {
  const publisher = createClient();
  const subscriber = createClient();

  await publisher.connect();
  await subscriber.connect();

  await subscriber.subscribe('channel', (message) => {
    console.log(message); // Output: 'Hello, World!'
  });

  await publisher.publish('channel', 'Hello, World!');

  // Give some time for the message to be received
  setTimeout(async () => {
    await publisher.disconnect();
    await subscriber.disconnect();
  }, 1000);
})();

Other packages similar to @redis/client

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