fix getting link from cache

This commit is contained in:
Pouria Ezzati 2025-01-07 22:01:20 +03:30
parent 0fc37b36ab
commit e0ae010f37
2 changed files with 2 additions and 2 deletions

View File

@ -172,7 +172,7 @@ async function getAdmin(match, params) {
} }
async function find(match) { async function find(match) {
if (match.address && match.domain_id && env.REDIS_ENABLED) { if (match.address && match.domain_id !== undefined && env.REDIS_ENABLED) {
const key = redis.key.link(match.address, match.domain_id); const key = redis.key.link(match.address, match.domain_id);
const cachedLink = await redis.client.get(key); const cachedLink = await redis.client.get(key);
if (cachedLink) return JSON.parse(cachedLink); if (cachedLink) return JSON.parse(cachedLink);

View File

@ -14,7 +14,7 @@ if (env.REDIS_ENABLED) {
} }
const key = { const key = {
link: (address, domain_id, user_id) => `l:${address}:${domain_id || ""}:${user_id || ""}`, link: (address, domain_id) => `l:${address}:${domain_id || ""}`,
domain: (address) => `d:${address}`, domain: (address) => `d:${address}`,
stats: (link_id) => `s:${link_id}`, stats: (link_id) => `s:${link_id}`,
host: (address) => `h:${address}`, host: (address) => `h:${address}`,