This commit is contained in:
Samy Pessé
2023-12-12 19:28:34 +01:00
parent ee0b3c2032
commit fff0ea8c34
3 changed files with 7 additions and 0 deletions
+1
View File
@@ -56,6 +56,7 @@ export const getPublishedContentByUrl = cache(
// If the request is aborted, we don't need to make the API call
// We call it as this logic is wrapped in an asynchronous cache that is not tied to the signal.
console.log('getPublishedContentByUrl', signal?.aborted);
signal?.throwIfAborted();
const gitbook = new GitBookAPI({
+4
View File
@@ -100,7 +100,9 @@ async function getCacheValue(key: string) {
}
if (redis) {
console.log('getCacheValue', key);
const value = await wrapOperation(redis.get(key));
console.log('done getCacheValue', key);
return value;
}
@@ -114,11 +116,13 @@ async function setCacheValue(key: string, value: any, ttl: number) {
memoryCache.set(key, value);
if (redis) {
console.log('setCacheValue', key);
await wrapOperation(
redis.set(key, value, {
ex: ttl,
}),
);
console.log('done setCacheValue', key);
}
}
+2
View File
@@ -241,6 +241,7 @@ async function lookupSpaceByAPI(
Promise.all(
lookupAlternatives.map(async (alternative) => {
console.log(`lookup content for url "${alternative.url}"`)
const data = await getPublishedContentByUrl(
alternative.url,
apiEndpoint,
@@ -254,6 +255,7 @@ async function lookupSpaceByAPI(
return;
}
resolved = true;
console.log('aborting');
abort.abort();
if (alternative.url === url.toString()) {