New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@volt.js/adapter-redis

Package Overview
Dependencies
Maintainers
2
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@volt.js/adapter-redis

[![NPM Version](https://img.shields.io/npm/v/@volt.js/adapter-redis.svg)](https://www.npmjs.com/package/@volt.js/adapter-redis) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

latest
npmnpm
Version
0.1.1
Version published
Maintainers
2
Created
Source

@volt.js/adapter-redis

NPM Version License: MIT

The official Redis adapter for the Volt.js Store system. This package provides a high-performance driver for caching and pub/sub messaging using a Redis data store.

Role in the Ecosystem

This adapter acts as the concrete implementation for the abstract Store interface defined in @volt.js/core. By plugging this adapter into your application, you enable powerful features:

  • Caching: A fast, Redis-backed key-value cache for storing the results of expensive operations.
  • Pub/Sub: A message bus for building real-time, event-driven features.
  • Shared Connection: The Redis client from this adapter can be shared with other systems, like the Volt.js Queues (BullMQ) adapter, for maximum efficiency.

Installation

To use this adapter, you need to install it along with its peer dependency, ioredis.

# npm
npm install @volt.js/adapter-redis ioredis

# yarn
yarn add @volt.js/adapter-redis ioredis

# pnpm
pnpm add @volt.js/adapter-redis ioredis

# bun
bun add @volt.js/adapter-redis ioredis

Basic Usage

The primary export of this package is the createRedisStoreAdapter factory function.

1. Create the Adapter Instance

First, create an instance of the ioredis client and pass it to the adapter factory. This is typically done in a dedicated service file.

// src/services/store.ts
import { createRedisStoreAdapter } from '@volt.js/adapter-redis';
import { Redis } from 'ioredis';

// It's recommended to configure your Redis connection via environment variables.
const redis = new Redis(process.env.REDIS_URL);

/**
 * The Store adapter for data persistence and messaging.
 */
export const store = createRedisStoreAdapter({
  client: redis,
  // Optional: A global prefix for all keys stored by this adapter.
  keyPrefix: 'volt-app:',
});

2. Register with the Volt Builder

Next, enable the Store feature in your main volt.ts file by passing your store adapter instance to the .store() method on the builder.

// src/volt.ts
import { Volt } from '@volt.js/core';
import { store } from './services/store';

export const volt = Volt
  .context<AppContext>()
  .store(store) // Enable the Store feature
  .create();

Your application is now configured to use Redis for caching and pub/sub. You can access the store's methods via volt.store or context.store within your actions.

Example of use in an action:

handler: async ({ context, response }) => {
  // Set a value in the cache with a 1-hour TTL
  await context.store.set('user:123', { name: 'John Doe' }, { ttl: 3600 });

  // Get the value
  const user = await context.store.get('user:123');

  return response.success({ user });
}

For more detailed guides, please refer to the Official Volt.js Wiki.

Contributing

Contributions are welcome! Please see the main CONTRIBUTING.md file for details on how to get started.

License

This package is licensed under the MIT License.

FAQs

Package last updated on 23 Aug 2025

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