Skip to content

[Bug] Redis Cache Issue #401

@talentestors

Description

@talentestors

Fix Boolean Environment Variable Parsing For Redis Cache Enablement

The ENABLE_REDIS environment variable setting in .env file has no effect when set to false.

ENABLE_REDIS=false

No effect!

Because:

const enableCache = Deno.env.get("ENABLE_REDIS") || false;

Deno.env.get("ENABLE_REDIS") is string type.

However, if (!enableCache) condition fails because 'enableCache' contains the string 'false', which is truthy when coerced to boolean.

Fix: const enableCache: boolean = Deno.env.get("ENABLE_REDIS") === 'true';

Redis Support Tls

  async connect(): Promise<void> {
    if (!enableCache) return;
    this.client = await connect({
      hostname: Deno.env.get("REDIS_HOST") || "",
      port: Number(Deno.env.get("REDIS_PORT")) || 6379,
      username: Deno.env.get("REDIS_USERNAME") || "",
      password: Deno.env.get("REDIS_PASSWORD") || "",
+     tls: Deno.env.get("TLS") === 'true',
    });
  }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions