Redis Server Manager

1.2.2 · abandoned · verified Sun Apr 19

This `redis-server` package, currently at version 1.2.2 (last published June 2018), provides a programmatic interface to start and stop a local Redis server instance within Node.js applications. It's primarily intended for testing or local development environments, simplifying the lifecycle management of a Redis process from within Node.js. The package acts as a wrapper for the native `redis-server` executable, requiring it to be pre-installed on the system or a custom path provided in the configuration. Due to its age and lack of recent updates, it primarily supports CommonJS and older Node.js versions, lacking modern ESM support and potentially having compatibility issues with newer Node.js runtime features. There is no active development, marking it as an abandoned package.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to programmatically start a local Redis server instance, connect a standard Redis client (like `node-redis`) to it, perform a basic key-value operation, and then gracefully shut down both the client and the server.

const RedisServer = require('redis-server');
const { createClient } = require('redis'); // A typical Redis client

const PORT = 6379;
const server = new RedisServer({ port: PORT });

async function startRedisAndConnect() {
  try {
    console.log(`Attempting to open Redis server on port ${PORT}...`);
    await server.open();
    console.log(`Redis server running on port ${PORT}.`);

    // Connect a Redis client to the newly started server
    const client = createClient({ url: `redis://localhost:${PORT}` });
    client.on('error', (err) => console.error('Redis Client Error:', err));

    await client.connect();
    console.log('Redis client connected.');

    // Perform a simple Redis operation
    await client.set('mykey', 'Hello, Redis!');
    const value = await client.get('mykey');
    console.log(`Retrieved from Redis: ${value}`);

    // Close the client and then the server
    await client.disconnect();
    console.log('Redis client disconnected.');

  } catch (err) {
    console.error('Failed to start or connect to Redis server:', err);
  } finally {
    console.log('Attempting to close Redis server...');
    await server.close();
    console.log('Redis server closed.');
  }
}

startRedisAndConnect();

view raw JSON →