Redis Methods
Hysteria ORM provides both static (singleton) and instance methods for Redis operations.
Supported Types
string
,number
,boolean
,object
,array
,Buffer
Setting Values
await Redis.set('key', 'value', 1000); // expires in 1s
await redisInstance.set('key', { foo: 'bar' }, 5000);
Getting Values
const value = await Redis.get<string>('key');
const obj = await redisInstance.get<{ foo: string }>('key');
Buffers
await Redis.set('key', Buffer.from('value'), 1000);
const buffer = await Redis.getBuffer('key');
Consuming (get and delete)
const value = await Redis.consume<string>('key');
Deleting
await Redis.delete('key');
Flushing All
await Redis.flushAll();
Best Practices
- Use expiry for cache keys.
- Use type parameters for type safety.
- Use instance methods for isolated connections.
Next: Advanced Utilities