Redis Introduction
Hysteria ORM provides a simple, type-safe interface for Redis, supporting both singleton and instance-based connections.
Key Features
- Built on top of
ioredis
- Singleton and instance connection modes
- Type-safe set/get for strings, numbers, booleans, objects, arrays, buffers
- Expiry, consume, and flush operations
- Access to raw ioredis connection
Example Usage
import { Redis } from 'hysteria-orm';
// Singleton connection
await Redis.connect({ host: 'localhost', port: 6379 });
await Redis.set('key', 'value', 1000);
const value = await Redis.get<string>('key');
// Instance connection
const redisInstance = await Redis.getConnection({ host: 'localhost', port: 6379 });
await redisInstance.set('key', 123);
const number = await redisInstance.get<number>('key');
Next: Redis Methods