Registry / database / lured
library1.0.3jsnpmunverified

Lured is a Lua script loader for Redis that simplifies loading and managing multiple Lua scripts. Version 1.0.3 is the latest stable release, with a slow release cadence. It automatically computes SHA1 hashes for each script and exposes them to the user, enabling direct use with EVALSHA in MULTI commands. Key differentiators: it provides SHA values for full control, supports auto-reload on reconnection, and optimizes with SCRIPT EXISTS before SCRIPT LOAD to reduce network traffic. Unlike other loaders that hide SHAs, lured gives developers access to them.

npm install lured
INSTALL
IMPORT
SIG · LURED
L
lured
databasejavascriptv1.0.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.

lured
import lured from 'lured';
const lured = require('lured').default;
ESM default import. CommonJS requires the whole module object.
create
import { create } from 'lured';
const create = require('lured').create;
Named export for creating lured instance.
LuredEventEmitter
import { EventEmitter } from 'events';
import { EventEmitter } from 'lured';
Lured uses Node's EventEmitter; events are emitted on the lured instance.

Creates a lured instance, loads a Lua script into Redis, and executes it using EVALSHA with the provided SHA.

import { create } from 'lured'; import { createClient } from 'redis'; const client = createClient(); const scripts = { greet: { script: 'return "Hello, world!"' } }; const lured = create(client, scripts); lured.load((err) => { if (err) { console.error('Failed to load scripts:', err); } else { // Now scripts.greet.sha contains the SHA1 hash client.evalsha(scripts.greet.sha, 0, (err, result) => { console.log(result); // 'Hello, world!' client.quit(); }); } });
Debug
Known issues
gotchaRedis client must be connected before calling lured.load().
fix
Ensure client is ready (e.g., listen to 'ready' event) before loading.
affects: >=1.0.0
gotchaScripts object is mutated: lured adds 'sha' properties to each script.
fix
Do not assume scripts object is immutable; SHAs are filled after load.
affects: >=1.0.0
breakingThe 'state' event changed payload in v1.0.0: now emits 'from-state' and 'to-state' numbers.
fix
Upgrade to v1.0.0+ and update event listeners to accept two arguments.
affects: <1.0.0
deprecatedThe 'scripts' getter is considered deprecated in favor of accessing the passed scripts object directly.
fix
Use the original scripts variable instead of lured.scripts.
affects: >=1.0.0
gotchaAuto-reload triggers on 'connect' event, which may fire multiple times (e.g., reconnects).
fix
Use the 'state' event to track actual readiness (state 3 = READY) instead of relying on load callback alone.
affects: >=1.0.0
Errors
Common errors & fixes
Error: Redis connection to 127.0.0.1:6379 failed - connect ECONNREFUSED
Redis server is not running or unreachable.
fix
Start Redis server: redis-server
TypeError: lured.create is not a function
Imported lured incorrectly; CommonJS require() returns the whole exports object.
fix
Use const lured = require('lured'); then lured.create(client, scripts);
ReferenceError: redis is not defined
Forgot to require or import the redis package.
fix
Install and require redis: npm install redis
TypeError: Cannot read property 'sha' of undefined
Script object not found in scripts; check key spelling.
fix
Verify scripts object keys (e.g., scripts.foo) exist and are correctly cased.
Upgrade
Version history
1.0.3latest on npm
Audit
Dependencies
redisrequiredLured requires a Redis client instance for script loading and state events.
Agent activity
8 hits · last 30 days
node
6
Resources
packagelured
lured — npm install lured · libregistry