Redis Introduction (Experimental)
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