Class that extends the BaseStore class to interact with an Upstash Redis database. It provides methods for getting, setting, and deleting data, as well as yielding keys from the database.

Example

const store = new UpstashRedisStore({
client: new Redis({
url: "your-upstash-redis-url",
token: "your-upstash-redis-token",
}),
});
await store.mset([
["message:id:0", "encoded-ai-message"],
["message:id:1", "encoded-human-message"],
]);
const retrievedMessages = await store.mget(["message:id:0", "message:id:1"]);
const yieldedKeys = [];
for await (const key of store.yieldKeys("message:id")) {
yieldedKeys.push(key);
}
await store.mdelete(yieldedKeys);

Hierarchy

  • BaseStore<string, Uint8Array>
    • UpstashRedisStore

Constructors

Properties

client: Redis
yieldKeysScanBatchSize: number = 1000
namespace?: string

Methods

  • Yields keys from the Upstash Redis database.

    Parameters

    • Optional prefix: string

      Optional prefix to filter the keys. A wildcard (*) is always appended to the end.

    Returns AsyncGenerator<string, any, unknown>

    An AsyncGenerator that yields keys from the Upstash Redis database.

Generated using TypeDoc