-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Closed
Description
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=falseNo 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
Labels
No labels