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