@da440dil/js-redis-script

Redis script runner


Keywords
redis, script, scripting, nodejs, typescript
License
MIT
Install
npm install @da440dil/js-redis-script@0.3.2

Documentation

js-redis-script

Build Status Coverage Status

Redis script runner.

It optimistically uses EVALSHA to run the script. If script does not exist it retries using EVAL.

Supported Redis clients: node-redis v3 and v4, ioredis v4.

Example usage with node-redis v4:

import { createClient } from 'redis';
import { createScript } from '@da440dil/js-redis-script';

async function main() {
	const client = createClient();
	await client.connect();

	const script = createScript(client, 'return redis.call("ping")');
	const reply = await script.run();
	console.log('PING', reply);
	// Output:
	// PING PONG

	await client.quit();
}

main().catch((err) => {
	console.error(err);
	process.exit(1);
});

Benchmarks

npm run benchmarks