Registry / database / redis-scripto

redis-scripto

JSON →
library0.1.3jsnpmunverified

redis-scripto (v0.1.3) is a Redis Lua script manager for Node.js (Node >= 0.8.x). It automates the process of loading Lua scripts into Redis using SCRIPT LOAD and executing them via EVALSHA for network efficiency, falling back to EVAL while scripts are loading. It also recovers from dropped connections by reloading scripts. Key differentiator: simplifies Redis Lua scripting in Node.js by managing script loading from directory, files, or inline JavaScript objects automatically. The package is stable but in maintenance mode, with no new features or updates since 2013. It uses callbacks and is not Promise/async-based. Alternative: use ioredis with built-in script management.

npm install redis-scripto
INSTALL
IMPORT
SIG · REDIS-SCRIPTO
R
redis-scripto
databasejavascriptv0.1.3
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-scripto');
import Scripto from 'redis-scripto';
Package uses CommonJS; no default ESM export. Also wrong: const { Scripto } = require('redis-scripto'); (it's just a function constructor)
Scripto (as class)
const Scripto = require('redis-scripto'); const manager = new Scripto(client);
const Scripto = require('redis-scripto'); const manager = Scripto(client);
Scripto must be instantiated with 'new'; calling it as a function throws TypeError.
Scripto (TypeScript)
const Scripto = require('redis-scripto'); // no type definitions, use @types/redis-scripto or declare module
import Scripto from 'redis-scripto';
No TypeScript declarations; must use require and custom type declarations.

Shows how to create a Scripto instance, load Lua scripts from a directory, and execute a script with keys and values using callback.

const redis = require('redis'); const Scripto = require('redis-scripto'); const client = redis.createClient(); const manager = new Scripto(client); // Load Lua scripts from a directory manager.loadFromDir('./lua'); // Run a script after loading const keys = ['mykey']; const values = ['hello']; manager.run('myscript', keys, values, function(err, result) { if (err) throw err; console.log('Result:', result); client.quit(); }); // If scripts not yet loaded, .run() falls back to EVAL // Once loaded, uses EVALSHA
Debug
Known issues
deprecatedPackage uses outdated redis driver (v0.12.x or earlier) which may have bugs and deprecated APIs.
fix
Upgrade to a modern Redis client like ioredis and use its built-in script loading (defineCommand) instead.
affects: >=0.0.0
breakingScripto constructor expects a redis client that obeys old API (e.g., .send_command). Using newer redis clients (v4+) may break.
fix
Use redis v2.x or switch to ioredis which has compatibility mode.
affects: >=0.0.0
gotcha.loadFromDir() uses synchronous fs.readdirSync and fs.readFileSync; will block event loop if directory has many files.
fix
For large directories, consider .load(scripts) with async loading.
affects: >=0.0.0
gotchaScript names are derived from filenames without extension; collisions occur if two files have same stem in different subdirectories.
fix
Ensure unique filenames or use .load() with explicit names.
affects: >=0.0.0
gotchaThe package does not handle script errors (e.g., syntax errors in Lua) gracefully; callback receives raw error from Redis.
fix
Wrap .run() in try-catch and validate Lua scripts externally.
affects: >=0.0.0
deprecatedPackage no longer maintained since 2013; no security updates or compatibility with modern Node versions.
fix
Migrate to ioredis or redis v4+ with built-in script management.
affects: >=0.0.0
Errors
Common errors & fixes
TypeError: Scripto is not a constructor
Using require result without 'new' or mistakenly thinking it's a named export (e.g., const { Scripto } = require('redis-scripto')).
fix
Correct: const Scripto = require('redis-scripto'); const manager = new Scripto(client);
Error: Redis connection to 127.0.0.1:6379 failed - connect ECONNREFUSED
Redis server not running or connection configuration incorrect.
fix
Start Redis server locally or check client connection options.
TypeError: client.send_command is not a function
Using newer redis client (v4+) that does not have the old send_command method.
fix
Use redis v2.x client or switch to ioredis which provides compatible API.
Error: ERR Error compiling script (new function): user_script:1: syntax error
Lua script has syntax error (e.g., missing 'end' in function).
fix
Debug and fix Lua script syntax before loading.
Error: Script not loaded, cannot run EVALSHA
Script not loaded (e.g., not called loadFromDir or load) or connection reset while script was not yet loaded.
fix
Call .loadFromDir() or .load() before .run(); check that loading completed.
Upgrade
Version history
0.1.3latest on npm
Audit
Dependencies
redisrequiredRedis client dependency required to interact with Redis server
Agent activity
15 hits · last 30 days
node
12
Meta
1
Resources
redis-scripto — npm install redis-scripto · libregistry