nextjs-redis-wrapper-fishwoo
v1.0.8
Published
A robust Redis client wrapper for Next.js applications
Maintainers
Readme
Next.js Redis Wrapper
A robust Redis client wrapper designed specifically for Next.js applications.
Features
- Singleton pattern for Redis client management
- TypeScript support with full type definitions
- Comprehensive error handling
- Support for all basic Redis operations:
- Strings
- Lists
- Pub/Sub
- Key management
- Configurable connection options
Installation
npm install nextjs-redis-wrapper
# or
yarn add nextjs-redis-wrapperUsage
Basic Usage
import { createRedisClient } from 'nextjs-redis-wrapper';
const redisClient = createRedisClient({
url: 'redis://localhost:6379',
password: 'yourpassword',
db: 0
});
// In a Next.js API route or Server Action
export async function getData() {
await redisClient.connect();
await redisClient.set('key', 'value');
const value = await redisClient.get('key');
return value;
}Pub/Sub Example
// Subscribe
await redisClient.subscribe('channel', (message, channel) => {
console.log(`Received ${message} from ${channel}`);
});
// Publish
await redisClient.publish('channel', 'Hello World!');API Documentation
See full API documentation here.
License
MIT
