{"id":46619,"library":"thunk-redis","title":"thunk-redis","description":"A thunk/promise-based Redis client for Node.js, version 2.2.4. It supports all Redis features including cluster, pipelining, transactions, and generators. Designed to be fast and leverage thunks for control flow, it also supports Promises via the `usePromise` option. Competing with ioredis and node_redis, it focuses on thunk/coroutine patterns and lower overhead. Released under the MIT license, with a stable API and regular maintenance.","status":"active","version":"2.2.4","language":"javascript","source_language":"en","source_url":"git://github.com/thunks/thunk-redis","tags":["javascript","redis","redis client","cluster","database","thunk","thunks","generator","promise"],"install":[{"cmd":"npm install thunk-redis","lang":"bash","label":"npm"},{"cmd":"yarn add thunk-redis","lang":"bash","label":"yarn"},{"cmd":"pnpm add thunk-redis","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Core dependency for thunk-based control flow and generator support.","package":"thunks","optional":false}],"imports":[{"note":"CommonJS require returns the module directly. ESM default import works with bundlers using the 'esModuleInterop' flag.","wrong":"const redis = require('thunk-redis').default","symbol":"default (createClient, calcSlot, log)","correct":"import redis from 'thunk-redis'"},{"note":"Both named import and require work, but require with destructuring is valid CommonJS.","wrong":"const { createClient } = require('thunk-redis')","symbol":"createClient","correct":"import { createClient } from 'thunk-redis'"},{"note":"log is a helper function available on the main export.","wrong":"require('thunk-redis').log('message')","symbol":"redis.log","correct":"import redis from 'thunk-redis'; redis.log('message')"}],"quickstart":{"code":"import redis from 'thunk-redis';\nimport thunk from 'thunks';\n\nconst client = redis.createClient({\n  host: '127.0.0.1',\n  port: 6379,\n  database: 0\n});\n\nclient.on('connect', () => {\n  console.log('Connected to Redis');\n});\n\nthunk(function* () {\n  yield client.set('key', 'value');\n  const val = yield client.get('key');\n  console.log('Got:', val);\n  yield client.del('key');\n  yield client.quit();\n})(err => {\n  if (err) console.error(err);\n});","lang":"javascript","description":"Connects to Redis, sets and gets a key using thunk-based control flow, then quits."},"warnings":[{"fix":"Use `yield [client.multi(), client.set(...), client.exec()]` pattern as shown in the documentation.","message":"Using `multi()` inside a thunk: `yield client.multi()` returns a thunk that must be yielded before other commands in the transaction.","severity":"gotcha","affected_versions":">=2.0.0"},{"fix":"Upgrade Node.js to >=4.5.0.","message":"Node.js >=4.5.0 requirement. Older Node versions are unsupported.","severity":"deprecated","affected_versions":">=2.0.0"},{"fix":"Set `cluster-require-full-coverage no` in redis.conf.","message":"Redis cluster requires `cluster-require-full-coverage` set to `no` in Redis config, otherwise operations may fail.","severity":"gotcha","affected_versions":">=2.0.0"},{"fix":"Add `{ usePromise: true }` to createClient options.","message":"When using Promises, you must set `usePromise: true` in options, otherwise client returns thunks that are not thenable.","severity":"gotcha","affected_versions":">=2.0.0"},{"fix":"Install `bluebird` or use native Promise (Node 4+).","message":"The `usePromise` option requires a global Promise or `bluebird`; if not available, an error is thrown.","severity":"gotcha","affected_versions":">=2.0.0"}],"env_vars":null,"search_vec":"'2.2.4':11 'also':34 'api':63 'client':7,70 'cluster':18,71 'compet':41 'control':31 'databas':72 'design':23 'fast':26 'featur':16 'flow':32 'focus':48 'generat':22,75 'includ':17 'ioredi':43 'javascript':67 'leverag':28 'licens':59 'lower':53 'mainten':66 'mit':58 'node':45 'node.js':9 'option':40 'overhead':54 'pattern':51 'pipelin':19 'promis':36,76 'redi':3,6,15,46,68,69 'regular':65 'releas':55 'stabl':62 'support':13,35 'thunk':2,29,73,74 'thunk-redi':1 'thunk/coroutine':50 'thunk/promise-based':5 'transact':20 'usepromis':39 'version':10 'via':37","created_at":"2026-06-07T13:00:48.295104+00:00","updated_at":"2026-06-07T13:00:48.295104+00:00","problems":[{"fix":"Use `const redis = require('thunk-redis');` for CommonJS or `import redis from 'thunk-redis';` for ES modules.","cause":"Importing incorrectly; using `const redis = require('thunk-redis').default` or wrong import style.","error":"TypeError: redis.createClient is not a function"},{"fix":"Run `npm install thunks` alongside `thunk-redis`.","cause":"Missing peer dependency `thunks` not installed.","error":"Error: Cannot find module 'thunks'"},{"fix":"Add `usePromise: true` to createClient options.","cause":"Using promise `.then()` without setting `usePromise: true`.","error":"TypeError: client.get(...).then is not a function"},{"fix":"Set `cluster-require-full-coverage no` in redis.conf.","cause":"Missing `cluster-require-full-coverage no` config in cluster mode.","error":"ERR Wrong number of arguments for 'cluster' command"}],"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/thunks/thunk-redis","github":"git://github.com/thunks/thunk-redis","docs":null,"changelog":null,"pypi":null,"npm":"thunk-redis","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}}