{"id":46606,"library":"then-redis-scripts","title":"then-redis-scripts","description":"Script runner for Redis that loads Lua scripts from the file system, caches them, and executes via EVALSHA with automatic reload on SCRIPT FLUSH. Version 2.2.0 is current, stable, with low release cadence. Designed for use with the node_redis client, it simplifies managing and running Lua scripts in Redis by handling script loading, caching, and error recovery. Differentiator: automatic script caching and re-fetching if scripts are flushed from Redis server.","status":"active","version":"2.2.0","language":"javascript","source_language":"en","source_url":"https://github.com/Janpot/then-redis-scripts","tags":["javascript","redis","promise","scripts","script"],"install":[{"cmd":"npm install then-redis-scripts","lang":"bash","label":"npm"},{"cmd":"yarn add then-redis-scripts","lang":"bash","label":"yarn"},{"cmd":"pnpm add then-redis-scripts","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency; the library wraps a node_redis client","package":"redis","optional":false},{"reason":"provides promisified redis client interface; required for promise-based run method","package":"then-redis-promise","optional":true}],"imports":[{"note":"Package provides CommonJS default export; ESM import not supported.","wrong":"import redisScripts from 'then-redis-scripts';","symbol":"default","correct":"var redisScripts = require('then-redis-scripts');"},{"note":"Export is a function, not a named export.","wrong":"const { redisScripts } = require('then-redis-scripts');","symbol":"default","correct":"const redisScripts = require('then-redis-scripts');"}],"quickstart":{"code":"const redis = require('redis');\nconst redisScripts = require('then-redis-scripts');\n\nconst client = redis.createClient();\nconst scripts = redisScripts(client, {\n  base: __dirname + '/lua'\n});\n\nscripts.run('my-lua-script', ['key'], ['argv1', 'argv2'])\n  .then(function (result) {\n    console.log(result);\n  })\n  .catch(function (err) {\n    console.error(err);\n  });","lang":"javascript","description":"Initialize script runner with a redis client and base path, then run a script with keys and args."},"warnings":[{"fix":"Pass 'my-script' instead of 'my-script.lua'.","message":"Script path resolution: `.lua` extension is added automatically; avoid double extension.","severity":"gotcha","affected_versions":">=0.1"},{"fix":"Use synchronous functions only for shared keys/args calculation.","message":"Shared scripts with on-the-fly key/arg functions require careful synchronous execution; async functions are not supported.","severity":"gotcha","affected_versions":">=0.1"},{"fix":"Use the 'redis' package from npm, not 'ioredis' or 'redis-mock'.","message":"Package depends on node_redis; does not work with ioredis or other Redis clients.","severity":"gotcha","affected_versions":">=0.1"}],"env_vars":null,"search_vec":"'2.2.0':30 'automat':24,64 'cach':17,59,66 'cadenc':37 'client':45 'current':32 'design':38 'differenti':63 'error':61 'evalsha':22 'execut':20 'fetch':70 'file':15 'flush':28,74 'handl':56 'javascript':78 'load':10,58 'low':35 'lua':11,51 'manag':48 'node':43 'promis':80 're':69 're-fetch':68 'recoveri':62 'redi':3,8,44,54,76,79 'releas':36 'reload':25 'run':50 'runner':6 'script':4,5,12,27,52,57,65,72,81,82 'server':77 'simplifi':47 'stabl':33 'system':16 'then-redis-script':1 'use':40 'version':29 'via':21","created_at":"2026-06-07T13:00:45.218045+00:00","updated_at":"2026-06-07T13:00:45.218045+00:00","problems":[{"fix":"Use `const redisScripts = require('then-redis-scripts');`","cause":"Incorrect import (named export instead of default) or using ESM import with CommonJS package.","error":"TypeError: redisScripts is not a function"},{"fix":"Ensure the Lua file exists at the resolved path relative to `base`.","cause":"Script file missing or base path misconfigured.","error":"Error: Cannot find module './lua/my-script.lua'"},{"fix":"Check the Lua script for syntax errors using redis-cli or debug the script.","cause":"Lua script syntax error or runtime error.","error":"Error: ERR Error running script (call to f_...): @user_script:1: ..."}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/Janpot/the-redis-scripts#readme","github":"https://github.com/Janpot/then-redis-scripts","docs":null,"changelog":null,"pypi":null,"npm":"then-redis-scripts","openapi_spec":null,"status_page":null,"smithery":null,"categories":["database"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}