Class that extends the BaseStore class to interact with a Redis database. It provides methods for getting, setting, and deleting data, as well as yielding keys from the database.
const store = new RedisByteStore({ client: new Redis({}) });await store.mset([ [ "message:id:0", new TextEncoder().encode(JSON.stringify(new AIMessage("ai stuff..."))), ], [ "message:id:1", new TextEncoder().encode( JSON.stringify(new HumanMessage("human stuff...")), ), ],]);const retrievedMessages = await store.mget(["message:id:0", "message:id:1"]);console.log(retrievedMessages.map((v) => new TextDecoder().decode(v)));const yieldedKeys = [];for await (const key of store.yieldKeys("message:id:")) { yieldedKeys.push(key);}console.log(yieldedKeys);await store.mdelete(yieldedKeys); Copy
const store = new RedisByteStore({ client: new Redis({}) });await store.mset([ [ "message:id:0", new TextEncoder().encode(JSON.stringify(new AIMessage("ai stuff..."))), ], [ "message:id:1", new TextEncoder().encode( JSON.stringify(new HumanMessage("human stuff...")), ), ],]);const retrievedMessages = await store.mget(["message:id:0", "message:id:1"]);console.log(retrievedMessages.map((v) => new TextDecoder().decode(v)));const yieldedKeys = [];for await (const key of store.yieldKeys("message:id:")) { yieldedKeys.push(key);}console.log(yieldedKeys);await store.mdelete(yieldedKeys);
Optional
Protected
Deletes multiple keys from the Redis database.
Array of keys to be deleted.
Promise that resolves when all keys have been deleted.
Gets multiple keys from the Redis database.
Array of keys to be retrieved.
An array of retrieved values.
Sets multiple keys in the Redis database.
Array of key-value pairs to be set.
Promise that resolves when all keys have been set.
Yields keys from the Redis database.
Optional prefix to filter the keys.
An AsyncGenerator that yields keys from the Redis database.
Class that extends the BaseStore class to interact with a Redis database. It provides methods for getting, setting, and deleting data, as well as yielding keys from the database.
Example