@graphql-mesh/cache-redis 0.104.3 → 0.104.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/cjs/index.js CHANGED
@@ -12,7 +12,33 @@ function interpolateStrWithEnv(str) {
12
12
  class RedisCache {
13
13
  constructor(options) {
14
14
  const lazyConnect = options.lazyConnect !== false;
15
- if ('sentinels' in options) {
15
+ if ('startupNodes' in options) {
16
+ const parsedUsername = interpolateStrWithEnv(options.username?.toString()) || cross_helpers_1.process.env.REDIS_USERNAME;
17
+ const parsedPassword = interpolateStrWithEnv(options.password?.toString()) || cross_helpers_1.process.env.REDIS_PASSWORD;
18
+ const parsedDb = interpolateStrWithEnv(options.db?.toString()) || cross_helpers_1.process.env.REDIS_DB;
19
+ const numDb = parseInt(parsedDb);
20
+ this.client = new ioredis_1.default.Cluster(options.startupNodes.map(s => ({
21
+ host: s.host && interpolateStrWithEnv(s.host),
22
+ port: s.port && parseInt(interpolateStrWithEnv(s.port)),
23
+ family: s.family && parseInt(interpolateStrWithEnv(s.family)),
24
+ })), {
25
+ dnsLookup: options.dnsLookupAsIs
26
+ ? (address, callback) => callback(null, address)
27
+ : undefined,
28
+ redisOptions: {
29
+ username: parsedUsername,
30
+ password: parsedPassword,
31
+ db: isNaN(numDb) ? undefined : numDb,
32
+ enableAutoPipelining: true,
33
+ ...(lazyConnect ? { lazyConnect: true } : {}),
34
+ tls: options.tls ? {} : undefined,
35
+ },
36
+ enableAutoPipelining: true,
37
+ enableOfflineQueue: true,
38
+ ...(lazyConnect ? { lazyConnect: true } : {}),
39
+ });
40
+ }
41
+ else if ('sentinels' in options) {
16
42
  this.client = new ioredis_1.default({
17
43
  name: options.name,
18
44
  sentinelPassword: options.sentinelPassword && interpolateStrWithEnv(options.sentinelPassword),
package/esm/index.js CHANGED
@@ -9,7 +9,33 @@ function interpolateStrWithEnv(str) {
9
9
  export default class RedisCache {
10
10
  constructor(options) {
11
11
  const lazyConnect = options.lazyConnect !== false;
12
- if ('sentinels' in options) {
12
+ if ('startupNodes' in options) {
13
+ const parsedUsername = interpolateStrWithEnv(options.username?.toString()) || process.env.REDIS_USERNAME;
14
+ const parsedPassword = interpolateStrWithEnv(options.password?.toString()) || process.env.REDIS_PASSWORD;
15
+ const parsedDb = interpolateStrWithEnv(options.db?.toString()) || process.env.REDIS_DB;
16
+ const numDb = parseInt(parsedDb);
17
+ this.client = new Redis.Cluster(options.startupNodes.map(s => ({
18
+ host: s.host && interpolateStrWithEnv(s.host),
19
+ port: s.port && parseInt(interpolateStrWithEnv(s.port)),
20
+ family: s.family && parseInt(interpolateStrWithEnv(s.family)),
21
+ })), {
22
+ dnsLookup: options.dnsLookupAsIs
23
+ ? (address, callback) => callback(null, address)
24
+ : undefined,
25
+ redisOptions: {
26
+ username: parsedUsername,
27
+ password: parsedPassword,
28
+ db: isNaN(numDb) ? undefined : numDb,
29
+ enableAutoPipelining: true,
30
+ ...(lazyConnect ? { lazyConnect: true } : {}),
31
+ tls: options.tls ? {} : undefined,
32
+ },
33
+ enableAutoPipelining: true,
34
+ enableOfflineQueue: true,
35
+ ...(lazyConnect ? { lazyConnect: true } : {}),
36
+ });
37
+ }
38
+ else if ('sentinels' in options) {
13
39
  this.client = new Redis({
14
40
  name: options.name,
15
41
  sentinelPassword: options.sentinelPassword && interpolateStrWithEnv(options.sentinelPassword),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphql-mesh/cache-redis",
3
- "version": "0.104.3",
3
+ "version": "0.104.4",
4
4
  "sideEffects": false,
5
5
  "peerDependencies": {
6
6
  "graphql": "*"
@@ -8,7 +8,7 @@
8
8
  "dependencies": {
9
9
  "@graphql-mesh/cross-helpers": "^0.4.10",
10
10
  "@graphql-mesh/string-interpolation": "0.5.8",
11
- "@graphql-mesh/types": "^0.104.3",
11
+ "@graphql-mesh/types": "^0.104.4",
12
12
  "@whatwg-node/disposablestack": "^0.0.6",
13
13
  "ioredis": "^5.3.2",
14
14
  "ioredis-mock": "^8.8.3",