Skip to content

Conversation

AyronK
Copy link
Collaborator

@AyronK AyronK commented Aug 5, 2025

Manual

import { createCluster } from "@redis/client";
import createRedisHandler from "@fortedigital/nextjs-cache-handler/redis-strings";
import { withAdapter } from "@fortedigital/nextjs-cache-handler/cluster/adapter";

const { hostname: redisHostName } = new URL(process.env.REDIS_URL);
redis = withAdapter(
  createCluster({
    rootNodes: [{ url: process.env.REDIS_URL }],

    // optional if you use TLS and need to resolve shards' ip to proper hostname
    nodeAddressMap(address) {
      const [_, port] = address.split(":");

      return {
        host: redisHostName,
        port: Number(port),
      };
    },
  })
);

// after using withAdapter you can use redis cluster instance as parameter for createRedisHandler
const redisCacheHandler = createRedisHandler({
  client: redis,
  keyPrefix: CACHE_PREFIX,
});

TODO

  • Change to 2.1.0

@AyronK AyronK requested review from mmatras and Ljonel August 5, 2025 14:57
@mwojslaw
Copy link

mwojslaw commented Aug 8, 2025

Hi @AyronK,

It seems that your solution might also be applicable to createSentinel. Am I correct in understanding that?

Thanks!

@AyronK
Copy link
Collaborator Author

AyronK commented Aug 11, 2025

Hi @AyronK,

It seems that your solution might also be applicable to createSentinel. Am I correct in understanding that?

Thanks!

Perhaps @mwojslaw, I can check as soon as we settle on implementation for cluster as it's not quite ready yet.

@AyronK AyronK changed the title redis-cluster-strings handler supporting Redis Cluster connection Support Redis Cluster connection Aug 12, 2025
@AyronK AyronK requested a review from Ljonel August 12, 2025 10:06
@AyronK AyronK mentioned this pull request Aug 12, 2025
@AyronK AyronK marked this pull request as ready for review August 12, 2025 10:38
@AyronK AyronK changed the base branch from master to canary August 25, 2025 11:58
@AyronK AyronK merged commit 81a2565 into canary Aug 25, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants