server: fix cache expiring
ci/woodpecker/push/lint-sw Pipeline failed Details
ci/woodpecker/push/lint-client Pipeline failed Details
ci/woodpecker/push/lint-foundkey-js Pipeline was successful Details
ci/woodpecker/push/lint-backend Pipeline failed Details
ci/woodpecker/push/build Pipeline was successful Details
ci/woodpecker/push/test Pipeline failed Details

This commit is contained in:
Johann150 2024-03-30 08:39:47 +01:00
parent 1af0687423
commit ac1ef641f5
Signed by: Johann150
GPG Key ID: 9EE6577A2A06F8F1
2 changed files with 2 additions and 2 deletions

View File

@ -82,7 +82,7 @@ export class Cache<T> {
// Items may have been removed in the meantime or this may be
// the initial call for the first key inserted into the cache.
const [expiredKey, expiredValue] = this.cache.entries().next().value;
if (expiredValue.date + this.lifetime >= Date.now()) {
if (expiredValue.date + this.lifetime <= Date.now()) {
// This item is due for expiration, so remove it.
this.cache.delete(expiredKey);
}

View File

@ -11,7 +11,7 @@ const cache = new Cache<Instance>(
if (host == null) return undefined;
const res = await Instances.findOneBy({ host });
return res ?? undefined;
} ,
},
);
export async function registerOrFetchInstanceDoc(idnHost: string): Promise<Instance> {