Registry / database / machinepack-redis

machinepack-redis

JSON →
library2.0.7jsnpmunverified

Structured Node.js bindings for Redis using the machinepack pattern. Version 2.0.7 is the latest stable release. Provides low-level Redis operations (get, set, publish, subscribe, etc.) designed as reusable building blocks for higher-level abstractions like Sails.js adapters. Not intended for direct use in most applications; prefer higher-level wrappers (e.g., sails-redis) for caching. Last updated in 2018, with infrequent releases.

npm install machinepack-redis
INSTALL
IMPORT
SIG · MACHINEPACK-REDIS
M
machinepack-redis
databasejavascriptv2.0.7
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

MachinepackRedis
const MachinepackRedis = require('machinepack-redis');
import MachinepackRedis from 'machinepack-redis';
This package is CommonJS only and does not support ESM imports. Use require().
get
const MachinepackRedis = require('machinepack-redis'); MachinepackRedis.get({ store: client, key: 'foo' }).exec(console.log);
const { get } = require('machinepack-redis');
Do not destructure; all operations are methods on the required object.
set
const MachinepackRedis = require('machinepack-redis'); MachinepackRedis.set({ store: client, key: 'foo', value: 'bar' }).exec(console.log);
import { set } from 'machinepack-redis';
Same as get: must use the full required object, not named imports.

Demonstrates creating a Redis client, setting a key, and getting its value using machinepack-redis.

const MachinepackRedis = require('machinepack-redis'); const redis = require('redis'); const client = redis.createClient({ host: process.env.REDIS_HOST || 'localhost', port: process.env.REDIS_PORT || 6379 }); // Set a key MachinepackRedis.set({ store: client, key: 'greeting', value: 'Hello, world!' }).exec({ error(err) { console.error('Error:', err); }, success() { console.log('Key set successfully.'); } }); // Get the key MachinepackRedis.get({ store: client, key: 'greeting' }).exec({ error(err) { console.error('Error:', err); }, success(result) { console.log('Value:', result); } }); client.quit();
Debug
Known issues
gotchaThis package is low-level and not intended for direct use. Use sails-redis for caching in Sails apps.
fix
Use sails-redis (https://npmjs.com/package/sails-redis) for higher-level caching.
affects: >=0.0.0
deprecatedThe 'redis' npm package (v2.x) used internally is in maintenance mode; consider migrating to redis@4.x or ioredis.
fix
Use a different Redis client like ioredis and adapt the calls.
affects: >=2.0.0
gotchaAll machine methods use the 'machine' package's .exec() pattern; errors must be handled via callbacks, not promises.
fix
Use .exec({ error: fn, success: fn }) or promisify it.
affects: >=0.0.0
gotchaThe package does not support ESM imports; only CommonJS require().
fix
Use require('machinepack-redis') instead of import.
affects: >=0.0.0
Errors
Common errors & fixes
Error: Cannot find module 'machinepack-redis'
Package not installed or incorrectly imported in ESM context.
fix
Run 'npm install machinepack-redis --save' and use require().
TypeError: MachinepackRedis.get is not a function
Attempting to destructure the module or using wrong import style.
fix
Use: const MachinepackRedis = require('machinepack-redis'); then MachinepackRedis.get(...).
MachinepackRedis.get(...).exec is not a function
Missing machine dependency or incorrect usage of the method.
fix
Ensure 'machine' is installed and use the correct signature: .exec({ error, success }).
Upgrade
Version history
2.0.7latest on npm
Audit
Dependencies
machinerequiredCore machinepack runtime for defining and running machines
redisrequiredNode.js Redis client driver used for all Redis operations
Agent activity
8 hits · last 30 days
node
6
Resources
machinepack-redis — npm install machinepack-redis · libregistry