Registry / database / redis-scripto2

redis-scripto2

JSON →
library0.2.2jsnpmunverified

Fork of the original redis-scripto (by Arunoda) that provides an intelligent Lua script manager for Redis and Node.js. Version 0.2.2 is the latest stable release; it is a drop-in replacement that updates dependencies to work with modern Node.js (>= 0.8.x). Key differentiators: automatically loads scripts via SCRIPT LOAD and uses EVALSHA when possible to minimize network transfer; reverts to EVAL if connection drops; supports loading scripts from directory, file, or object. No major changes from the original package.

npm install redis-scripto2
INSTALL
IMPORT
SIG · REDIS-SCRIPTO2
R
redis-scripto2
databasejavascriptv0.2.2
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.

Scripto
const Scripto = require('redis-scripto2');
import Scripto from 'redis-scripto2';
This package is CommonJS-only; ESM import does not work.
Scripto (ESM workaround)
import Scripto from 'redis-scripto2';
ESM import may work in some environments but module is CJS; use createRequire for reliability.
Scripto (TypeScript)
const Scripto = require('redis-scripto2'); // or import Scripto = require('redis-scripto2');
import Scripto from 'redis-scripto2';
No TypeScript types provided; use @types/redis for Redis client typing.

Initialize Scripto, load Lua scripts from a directory or inline object, and run a script using run().

const redis = require('redis'); const Scripto = require('redis-scripto2'); const client = redis.createClient({ url: process.env.REDIS_URL || 'redis://localhost:6379' }); const manager = new Scripto(client); // Load from directory (assuming ./scripts has .lua files) const path = require('path'); manager.loadFromDir(path.join(__dirname, 'scripts')); // Define an inline script (for example) const scripts = { 'hello': 'return {KEYS[1], ARGV[1]}' }; manager.load(scripts); // Run the script manager.run('hello', ['mykey'], ['world'], (err, result) => { if (err) console.error(err); else console.log(result); // Output: ['mykey', 'world'] client.quit(); });
Debug
Known issues
gotchaScripto requires an active Redis connection; if connection drops, SHA cache is cleared and scripts are re-loaded on next run.
fix
Ensure redis client auto-reconnect is enabled; Scripto handles SHA re-registration automatically.
affects: >=0.0.0
gotchaScripto.loadFromDir() loads all .lua files; non-lua files are ignored.
fix
Only place .lua files in the scripts directory.
affects: >=0.1.0
deprecatedThe original redis-scripto package is unmaintained; this fork updates dependencies.
fix
Migrate to redis-scripto2 by simply changing the require path.
affects: >=0.0.0
Errors
Common errors & fixes
Error: ERR EVALSHA key [keys...] [args...] – script not found
Redis flushed scripts (e.g., after SCRIPT FLUSH) or SHA cache stale due to connection drop.
fix
Scripto automatically reloads scripts; ensure you are using the instance that handles reconnection, or manually call scriptManager.load(scripts) again.
TypeError: Cannot read property 'run' of undefined
Scripto instance not properly initialized or required incorrectly.
fix
Ensure you use `require('redis-scripto2')` correctly and instantiate with `new Scripto(client)`.
Error: Connection to Redis lost – reconnecting
Network issue or Redis server restart.
fix
Enable redis client auto-reconnect (default in node_redis). Scripto will re-register SHAs after reconnection.
Upgrade
Version history
0.2.2latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
10 hits · last 30 days
node
8
Meta
1
Resources
redis-scripto2 — npm install redis-scripto2 · libregistry