Skip to content

Commit 1e9d092

Browse files
committed
Log cacheKey
1 parent 269b194 commit 1e9d092

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

src/lib/cache.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,14 @@ function redisCacheKey(key: CacheKey) {
3232
.filter((component) => component != null)
3333
.join("|");
3434

35+
console.log(sha256(contents));
36+
3537
return sha256(contents);
3638
}
3739

3840
export async function getCachedImage(
3941
key: CacheKey,
40-
redis: Redis
42+
redis: Redis,
4143
): Promise<IconMetadata | null> {
4244
if (process.env["RAYCAST_IGNORE_CACHE"] === "true") {
4345
return null;
@@ -60,7 +62,7 @@ export async function getCachedImage(
6062

6163
export async function getMetadata(
6264
key: CacheKey,
63-
redis: Redis
65+
redis: Redis,
6466
): Promise<IconMetadata | null> {
6567
const redisKey = redisCacheKey(key);
6668
const payload = await redis.hgetall(redisKey);
@@ -86,7 +88,7 @@ export type CacheKey = {
8688
export async function setMetadata(
8789
key: CacheKey,
8890
metadata: IconMetadata,
89-
redis: Redis
91+
redis: Redis,
9092
) {
9193
const redisKey = redisCacheKey(key);
9294
await redis.hset(redisKey, metadata);
@@ -95,7 +97,7 @@ export async function setMetadata(
9597
export async function setMetadataPartial(
9698
key: CacheKey,
9799
partial: Partial<IconMetadata>,
98-
redis: Redis
100+
redis: Redis,
99101
) {
100102
const redisKey = redisCacheKey(key);
101103
await redis.hset(redisKey, partial);
@@ -112,7 +114,7 @@ export async function getStoredObject(key: string, services: Services) {
112114
new GetObjectCommand({
113115
Bucket: bucket,
114116
Key: key,
115-
})
117+
}),
116118
);
117119

118120
// Memory leak in S3 SDK if you don't consume the body; workaround based on:
@@ -159,7 +161,7 @@ export async function getOrStoreObject(blob: Blob, services: Services) {
159161
} else {
160162
resolve();
161163
}
162-
}
164+
},
163165
);
164166
});
165167
} catch (error) {
@@ -172,7 +174,7 @@ export async function getOrStoreObject(blob: Blob, services: Services) {
172174
export async function cacheFavicon(
173175
key: CacheKey,
174176
icon: Icon,
175-
services: Services
177+
services: Services,
176178
) {
177179
const { image, source } = icon;
178180
const { expiry } = image;
@@ -190,14 +192,14 @@ export async function cacheFavicon(
190192
expiry,
191193
lastAccess: new Date(),
192194
},
193-
redis
195+
redis,
194196
);
195197
}
196198

197199
async function cacheImage(
198200
image: IconImage,
199201
source: IconSource,
200-
services: Services
202+
services: Services,
201203
): Promise<{ objectKey: string } | null> {
202204
if (source.source === "link" && source.data) {
203205
const parsed = parseBase64DataURL(source.url);

0 commit comments

Comments
 (0)