Fly IO Redis with Node JS

I’m having a tough time understanding how to integrate fly IO redis into my node js application. I’m running a socket IO web server which uses redis pub/sub to keep different instances in sync. There is no need to store any data in the database at all. How do I connect it in my nodeJs application i.e. what code do I put if I’m using:

const redis = require("redis");
const redisAdapter = require("@socket.io/redis-adapter");

const pubClient = redis.createClient({ REDIS INFO HERE });
const subClient = pubClient.duplicate();

pubClient.on("error", err => console.error(err));
subClient.on("error", err => console.error(err));

pubClient.connect();
subClient.connect();

const adapter = redisAdapter.createAdapter(pubClient, subClient)

Also, would PostGres or Redis be better in this situation? Also, would performing pub/sub a lot sending a simple javascript Object (few bytes) cause the free Upstash quota to finish? Or does pub/sub not count as operations?

Upstash Redis in Fly.io | Upstash: Documentation suggests:

const client = redis.createClient(process.env.REDIS_URL);
``

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.