Registry / database / do-redis-request

do-redis-request

JSON →
library1.0.6jsnpmunverified

A lightweight Redis helper function that wraps Redis commands, simplifying async calls with automatic connection handling. Current stable version 1.0.6, low release cadence. Provides a unified interface for any Redis command, reducing boilerplate. Works alongside get-redis-client and drf. No built-in retry or error handling, minimal abstraction. Suitable for small projects or rapid prototyping where full Redis client overhead is unwanted.

npm install do-redis-request
INSTALL
IMPORT
SIG · DO-REDIS-REQUEST
D
do-redis-request
databasejavascriptv1.0.6
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.

doRedisRequest
import doRedisRequest from 'do-redis-request'
const doRedisRequest = require('do-redis-request').doRedisRequest
Default export; do not destructure.
doRedisRequest
const doRedisRequest = require('do-redis-request')
const { doRedisRequest } = require('do-redis-request')
CommonJS default import; destructuring results in undefined.

Connects to Redis, executes GET command for key 'redisKey', logs the value, then closes the connection.

'use strict'; const getRedisClient = require('get-redis-client'); const doRedisRequest = require('do-redis-request'); (async () => { const redisClient = getRedisClient(); const value = await doRedisRequest({ client: redisClient, command: 'get', redisArguments: ['redisKey'], }); console.log('results:', value); redisClient.quit(); })();
Debug
Known issues
gotchaThe 'client' option must be an active Redis client instance. Passing an undefined or closed client will cause a runtime error.
fix
Ensure the client is connected before calling doRedisRequest. Use get-redis-client or ioredis/redis to create a valid client.
affects: >=1.0.0
gotchaCommand names are case-sensitive; use lowercase strings like 'get', 'set', 'hgetall'.
fix
Always pass command names in lowercase.
affects: >=1.0.0
gotchaThe 'redisArguments' array must contain exactly the arguments expected by the Redis command (excluding the command name). Extra or missing arguments may cause errors or unexpected results.
fix
Consult Redis command documentation for correct argument order and count.
affects: >=1.0.0
gotchaNo automatic reconnection or retry logic. If the Redis connection drops mid-request, the promise rejects with a connection error.
fix
Implement your own retry mechanism or use a more robust library like ioredis.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: doRedisRequest is not a function
Incorrect import as named export, but it's a default export.
fix
Use `import doRedisRequest from 'do-redis-request'` (ESM) or `const doRedisRequest = require('do-redis-request')` (CJS).
TypeError: Cannot read properties of undefined (reading 'sendCommand')
The 'client' option is undefined or not a valid Redis client.
fix
Pass a connected Redis client instance to the 'client' option.
TypeError: client.quit is not a function
The client object does not have a quit method, likely not a Redis client.
fix
Use a Redis client from `get-redis-client` or another library that provides `quit`.
ReplyError: ERR wrong number of arguments for 'get' command
Incorrect number of arguments passed in 'redisArguments' for the command.
fix
Provide exactly one argument (the key) for GET command; e.g., 'redisArguments': ['myKey'].
Error: Redis connection to 127.0.0.1:6379 failed - connect ECONNREFUSED
Redis server is not running or unreachable.
fix
Start Redis server with `redis-server` or change client configuration to point to a running instance.
Upgrade
Version history
1.0.6latest on npm
Audit
Dependencies
get-redis-clientoptionalrecommended for creating a Redis client instance
Agent activity
7 hits · last 30 days
node
6
Resources
do-redis-request — npm install do-redis-request · libregistry