# redis-scripto

> Redis Lua Script Manager for NodeJS

Latest version **0.1.3** (published 2014-04-30) · 0 weekly downloads

## Install

```sh
npm install redis-scripto
pnpm add redis-scripto
yarn add redis-scripto
bun add redis-scripto
```

## Health

**Score 18/100 (F)** — status: abandoned.

Positive: has types package; no vulnerabilities.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.3 |
| Published | 2014-04-30 |
| First published | 2013-02-27 |
| Weekly downloads | 0 |
| TypeScript types | separate (@types/redis-scripto) |
| Module format | CommonJS |
| Node | >= 0.8.x |
| Dependencies | 2 |
| Known vulnerabilities | 0 (+2 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 51 |
| Author | Arunoda Susiripala |
| Maintainers | arunoda |
| Keywords | redis, script, lua, manager, eval |

## Links

- npm: https://www.npmjs.com/package/redis-scripto
- Repository: https://github.com/arunoda/node-redis-scripto
- Issues: https://github.com/arunoda/node-redis-scripto/issues
- npm.io page: https://npm.io/package/redis-scripto

## Dependencies (2)

- [debug](https://npm.io/package/debug.md) 0.7.x
- [redis](https://npm.io/package/redis.md) 0.8.x

## Alternatives

- [memory-cache](https://npm.io/package/memory-cache.md) — 795.0K weekly downloads
- [@httptoolkit/proxy-agent](https://npm.io/package/@httptoolkit/proxy-agent.md) — 11.2K weekly downloads
- [express-cache-controller](https://npm.io/package/express-cache-controller.md) — 5.3K weekly downloads
- [http-cache-middleware](https://npm.io/package/http-cache-middleware.md) — 4.5K weekly downloads
- [cache2](https://npm.io/package/cache2.md) — 1.5K weekly downloads

## Recent versions

- 0.1.3 (latest) — 2014-04-30
- 0.1.2 — 2013-03-02
- 0.1.1 — 2013-02-27

## README

[![Build Status](https://travis-ci.org/arunoda/node-redis-scripto.png)](https://travis-ci.org/arunoda/node-redis-scripto)
node-redis-scripto
==================

### Intelligent Redis Lua Script Manager for NodeJS

* Lua Scripting on Redis (2.6+) is a killer feature
* But using them with NodeJs is painful
* We've to maintain lua script in JavaScript as string or load them via the filesystem manually
* If we are looking at network performance, we've to manually invoke `script load` and `evasha` manually

## Scripto manages lua scripts for you

* You can place lua script in a directory
* Just tell the `dirname` to `scripto`, it will take care of lua scripts

~~~js
    var Scripto = require('redis-scripto');
    var scriptManager = new Scripto(redisClient);
    scriptManager.loadFromDir('/path/to/lua/scripts');

    var keys    = ['keyOne', 'keyTwo'];
    var values  = [10, 20];
    scriptManager.run('your-script', keys, values, function(err, result) {

    });
~~~

## Scripto is intelligent

* By default `scripto` tries to load scripts into redis (via `script load`)
* While scripts are loading, if a script invoked with `.run()` it will use `eval` and send the plaintext lua script to redis
* After scripts loaded, if a script invoked with `.run()` it will use `evalsha` and does not send plaintext lua script 
* If the connection to redis dropped, it will remove shas and try again to load scripts once it back online

## You've the control with Scripto

* if you need to send the plaintext lua script always. use `.eval()` method

~~~js
    scriptManager.eval('your-script', keys, values, function(err, result) {

    });
~~~

* If you just need to load a single script, see following example

~~~js
    var scriptManager = new Scripto(redisClient);
    scriptManager.loadFromFile('script-one', '/path/to/the/file');
    scriptManager.run('script-one', [], [], function(err, result) {

    });
~~~

* If you need to load scripts just using JavaScript (without loading from the filesystem), see following example.

~~~js
    var scripts = {
        'script-one': 'return 1000'
    };

    var scriptManager = new Scripto(redisClient);
    scriptManager.load(scripts);
    scriptManager.run('script-one', [], [], function(err, result) {

    });
~~~

---
_Source: https://npm.io/package/redis-scripto · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
