This tutorial demonstrates how to use the RedisPersistence
class from the @xmtp/redis-persistence
package, part of the bot-kit-pro
monorepo, to enable XMTP client data persistence in a Redis database.
First, install the package in your project:
yarn add @xmtp/redis-persistence
Connect to your Redis instance:
const { createClient } = require("@redis/client")
const redis = createClient({
url: "redis://localhost:6379",
})
redis.connect()
Integrate RedisPersistence
with your XMTP client:
const { RedisPersistence } = require("@xmtp/redis-persistence")
const { createClient: createXmtpClient } = require("@xmtp/xmtp-js")
// XMTP client setup
const xmtpClient = createXmtpClient({
// Your XMTP client configuration
basePersistence: new RedisPersistence(redis, "xmtp:"),
})
If you want to contribute to this package, here are the steps to set up the project for development:
- Test Database Connection:
yarn start-redis
- Run Tests:
Validate your setup:
yarn test