Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

Never expire cache for links with webhooks.

Kiran K7799fd32bb77
diff --git a/apps/web/lib/api/links/cache.ts b/apps/web/lib/api/links/cache.ts
index 240a470f77..30800f2946 100644
--- a/apps/web/lib/api/links/cache.ts
+++ b/apps/web/lib/api/links/cache.ts
@@ -19,22 +19,33 @@ class LinkCache {
})),
);
- redisLinks.map(({ domain, key, ...redisLink }) =>
- pipeline.set(this._createKey({ domain, key }), redisLink, {
- ex: CACHE_EXPIRATION,
- }),
- );
+ redisLinks.map(({ domain, key, ...redisLink }) => {
+ const hasWebhooks =
+ redisLink.webhookIds && redisLink.webhookIds.length > 0;
+
+ pipeline.set(
+ this._createKey({ domain, key }),
+ redisLink,
+ // @ts-ignore
+ {
+ ...(!hasWebhooks && { ex: CACHE_EXPIRATION }),
+ },
+ );
+ });
return await pipeline.exec();
}
async set(link: LinkProps & { webhookIds?: string[] }) {
const redisLink = await formatRedisLink(link);
+ const hasWebhooks = redisLink.webhookIds && redisLink.webhookIds.length > 0;
+
return await redis.set(
this._createKey({ domain: link.domain, key: link.key }),
redisLink,
+ // @ts-ignore
{
- ex: CACHE_EXPIRATION,
+ ...(!hasWebhooks && { ex: CACHE_EXPIRATION }),
},
);
}