js-redis-script
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);
});
npm run benchmarks