$ npm install lured
- Makes easier for cumbersom script loading and management
- Supports multiple scripts
- Simple, intuitive and non-intrusive.
- SHA values are available to user. User still has a full control. (See [Usage] section)
- Automatically reload scripts after a reconnection. (assuming script cache may be wiped out)
- When loading, it will try SCRIPT EXISTS before performing SCRIPT LOAD to reduce network resource usage.
- create(redisClient, scripts) -
Creates an instance of lured. The
scriptsis an object in with the following structure:
var scripts =foo:script: "return 1" // your lua script for 'foo'sha: "e0e1f9fabfc9d4800c877a703b823ac0578ff8db" // filled by luredbar:script: "return 2" // your lua script for 'bar'sha: "7f923f79fe76194c868d7e1d0820de36700eb649" // filled by lured;
sha properties are automatically filled by lured.
- lured.load(cb) - Load given scripts, then set shas to the scripts object.
- lured.scripts (getter) - Returns the scripts object. (just for convenience)
- Event: 'state' - Emits (using EventEmitter) state change. Possible states are; 0:CLOSED, 1:CONNECTED, 2:LOADING and 3:READY. Registered handler will have two arguments: from-state and to-state.
var fs =var scripts =foo:script: fsbar:script: fs;var client = ;var lured = ;// Load all scripts on to redis server.lured;
When redis client emits 'connect' event, lured will check if the scripts are still cached, if not it will reload the scripts for you. If you need to track down the underlying behavior, set a listener on 'state' event.
Why lured while there are other similar script loaders?
Script loading and management is pain. So, looked for a good tool. I wanted to use SHA values so that I can use MULTI with mixture of the scripts and other commands, but the tools I came across hide many good stuff including the SHA values, and here comes the