Skip to content
This repository has been archived by the owner on Jan 16, 2025. It is now read-only.

Latest commit

 

History

History
56 lines (38 loc) · 1.17 KB

File metadata and controls

56 lines (38 loc) · 1.17 KB

XMTP Persistence with Redis

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.

Usage

First, install the package in your project:

yarn add @xmtp/redis-persistence

Step 1: Create a Redis Client

Connect to your Redis instance:

const { createClient } = require("@redis/client")
const redis = createClient({
  url: "redis://localhost:6379",
})
redis.connect()

Step 2: Implement RedisPersistence

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:"),
})

Development

If you want to contribute to this package, here are the steps to set up the project for development:

  1. Test Database Connection:
yarn start-redis
  1. Run Tests:

Validate your setup:

yarn test