Registry / database / thunk-redis

thunk-redis

JSON →
library2.2.4jsnpmunverified

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.

npm install thunk-redis
INSTALL
IMPORT
SIG · THUNK-REDIS
T
thunk-redis
databasejavascriptv2.2.4
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default (createClient, calcSlot, log)
✓ import redis from 'thunk-redis'
✗ const redis = require('thunk-redis').default
CommonJS require returns the module directly. ESM default import works with bundlers using the 'esModuleInterop' flag.
createClient
✓ import { createClient } from 'thunk-redis'
✗ const { createClient } = require('thunk-redis')
Both named import and require work, but require with destructuring is valid CommonJS.
redis.log
✓ import redis from 'thunk-redis'; redis.log('message')
✗ require('thunk-redis').log('message')
log is a helper function available on the main export.

Connects to Redis, sets and gets a key using thunk-based control flow, then quits.

import redis from 'thunk-redis'; import thunk from 'thunks'; const client = redis.createClient({ host: '127.0.0.1', port: 6379, database: 0 }); client.on('connect', () => { console.log('Connected to Redis'); }); thunk(function* () { yield client.set('key', 'value'); const val = yield client.get('key'); console.log('Got:', val); yield client.del('key'); yield client.quit(); })(err => { if (err) console.error(err); });
Debug
Known issues
gotchaUsing `multi()` inside a thunk: `yield client.multi()` returns a thunk that must be yielded before other commands in the transaction.
fix
Use `yield [client.multi(), client.set(...), client.exec()]` pattern as shown in the documentation.
affects: >=2.0.0
deprecatedNode.js >=4.5.0 requirement. Older Node versions are unsupported.
fix
Upgrade Node.js to >=4.5.0.
affects: >=2.0.0
gotchaRedis cluster requires `cluster-require-full-coverage` set to `no` in Redis config, otherwise operations may fail.
fix
Set `cluster-require-full-coverage no` in redis.conf.
affects: >=2.0.0
gotchaWhen using Promises, you must set `usePromise: true` in options, otherwise client returns thunks that are not thenable.
fix
Add `{ usePromise: true }` to createClient options.
affects: >=2.0.0
gotchaThe `usePromise` option requires a global Promise or `bluebird`; if not available, an error is thrown.
fix
Install `bluebird` or use native Promise (Node 4+).
affects: >=2.0.0
Errors
Common errors & fixes
TypeError: redis.createClient is not a function
Importing incorrectly; using `const redis = require('thunk-redis').default` or wrong import style.
fix
Use `const redis = require('thunk-redis');` for CommonJS or `import redis from 'thunk-redis';` for ES modules.
Error: Cannot find module 'thunks'
Missing peer dependency `thunks` not installed.
fix
Run `npm install thunks` alongside `thunk-redis`.
TypeError: client.get(...).then is not a function
Using promise `.then()` without setting `usePromise: true`.
fix
Add `usePromise: true` to createClient options.
ERR Wrong number of arguments for 'cluster' command
Missing `cluster-require-full-coverage no` config in cluster mode.
fix
Set `cluster-require-full-coverage no` in redis.conf.
Upgrade
Version history
2.2.4latest on npm
Audit
Dependencies
thunksrequiredCore dependency for thunk-based control flow and generator support.
Agent activity
15 hits · last 30 days
node
14
OpenAI (training)
1
Resources
thunk-redis — npm install thunk-redis · libregistry