{"library":"redis-server","title":"Redis Server Manager","description":"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.","language":"javascript","status":"abandoned","last_verified":"Sun Apr 19","install":{"commands":["npm install redis-server"],"cli":null},"imports":["const RedisServer = require('redis-server');"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"const RedisServer = require('redis-server');\nconst { createClient } = require('redis'); // A typical Redis client\n\nconst PORT = 6379;\nconst server = new RedisServer({ port: PORT });\n\nasync function startRedisAndConnect() {\n  try {\n    console.log(`Attempting to open Redis server on port ${PORT}...`);\n    await server.open();\n    console.log(`Redis server running on port ${PORT}.`);\n\n    // Connect a Redis client to the newly started server\n    const client = createClient({ url: `redis://localhost:${PORT}` });\n    client.on('error', (err) => console.error('Redis Client Error:', err));\n\n    await client.connect();\n    console.log('Redis client connected.');\n\n    // Perform a simple Redis operation\n    await client.set('mykey', 'Hello, Redis!');\n    const value = await client.get('mykey');\n    console.log(`Retrieved from Redis: ${value}`);\n\n    // Close the client and then the server\n    await client.disconnect();\n    console.log('Redis client disconnected.');\n\n  } catch (err) {\n    console.error('Failed to start or connect to Redis server:', err);\n  } finally {\n    console.log('Attempting to close Redis server...');\n    await server.close();\n    console.log('Redis server closed.');\n  }\n}\n\nstartRedisAndConnect();\n","lang":"javascript","description":"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.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}