summaryrefslogtreecommitdiff
path: root/packages/backend/src
diff options
context:
space:
mode:
authorHazel K <acomputerdog@gmail.com>2024-08-03 13:42:23 -0400
committerHazel K <acomputerdog@gmail.com>2024-08-03 13:42:23 -0400
commitbc236a4bd250fc700bdd2d5549bf9647c02cb946 (patch)
treea2f23b5ff113d2ae118c865ead5ec7cfb92b2801 /packages/backend/src
parentencapsulate `MemoryKVCache<T>` (diff)
downloadsharkey-bc236a4bd250fc700bdd2d5549bf9647c02cb946.tar.gz
sharkey-bc236a4bd250fc700bdd2d5549bf9647c02cb946.tar.bz2
sharkey-bc236a4bd250fc700bdd2d5549bf9647c02cb946.zip
remove infinity caches
Diffstat (limited to 'packages/backend/src')
-rw-r--r--packages/backend/src/core/CacheService.ts8
-rw-r--r--packages/backend/src/core/UserKeypairService.ts2
-rw-r--r--packages/backend/src/core/activitypub/ApDbResolverService.ts4
-rw-r--r--packages/backend/src/server/api/AuthenticateService.ts2
4 files changed, 8 insertions, 8 deletions
diff --git a/packages/backend/src/core/CacheService.ts b/packages/backend/src/core/CacheService.ts
index 4afcef02be..6725ebe75b 100644
--- a/packages/backend/src/core/CacheService.ts
+++ b/packages/backend/src/core/CacheService.ts
@@ -56,10 +56,10 @@ export class CacheService implements OnApplicationShutdown {
) {
//this.onMessage = this.onMessage.bind(this);
- this.userByIdCache = new MemoryKVCache<MiUser>(Infinity);
- this.localUserByNativeTokenCache = new MemoryKVCache<MiLocalUser | null>(Infinity);
- this.localUserByIdCache = new MemoryKVCache<MiLocalUser>(Infinity);
- this.uriPersonCache = new MemoryKVCache<MiUser | null>(Infinity);
+ this.userByIdCache = new MemoryKVCache<MiUser>(1000 * 60 * 5); // 5m
+ this.localUserByNativeTokenCache = new MemoryKVCache<MiLocalUser | null>(1000 * 60 * 5); // 5m
+ this.localUserByIdCache = new MemoryKVCache<MiLocalUser>(1000 * 60 * 5); // 5m
+ this.uriPersonCache = new MemoryKVCache<MiUser | null>(1000 * 60 * 5); // 5m
this.userProfileCache = new RedisKVCache<MiUserProfile>(this.redisClient, 'userProfile', {
lifetime: 1000 * 60 * 30, // 30m
diff --git a/packages/backend/src/core/UserKeypairService.ts b/packages/backend/src/core/UserKeypairService.ts
index 51ac99179a..eb7a95da3e 100644
--- a/packages/backend/src/core/UserKeypairService.ts
+++ b/packages/backend/src/core/UserKeypairService.ts
@@ -25,7 +25,7 @@ export class UserKeypairService implements OnApplicationShutdown {
) {
this.cache = new RedisKVCache<MiUserKeypair>(this.redisClient, 'userKeypair', {
lifetime: 1000 * 60 * 60 * 24, // 24h
- memoryCacheLifetime: Infinity,
+ memoryCacheLifetime: 1000 * 60 * 60 * 12, // 12h
fetcher: (key) => this.userKeypairsRepository.findOneByOrFail({ userId: key }),
toRedisConverter: (value) => JSON.stringify(value),
fromRedisConverter: (value) => JSON.parse(value),
diff --git a/packages/backend/src/core/activitypub/ApDbResolverService.ts b/packages/backend/src/core/activitypub/ApDbResolverService.ts
index 44680a2ed5..062af39732 100644
--- a/packages/backend/src/core/activitypub/ApDbResolverService.ts
+++ b/packages/backend/src/core/activitypub/ApDbResolverService.ts
@@ -54,8 +54,8 @@ export class ApDbResolverService implements OnApplicationShutdown {
private cacheService: CacheService,
private apPersonService: ApPersonService,
) {
- this.publicKeyCache = new MemoryKVCache<MiUserPublickey | null>(Infinity);
- this.publicKeyByUserIdCache = new MemoryKVCache<MiUserPublickey | null>(Infinity);
+ this.publicKeyCache = new MemoryKVCache<MiUserPublickey | null>(1000 * 60 * 60 * 12); // 12h
+ this.publicKeyByUserIdCache = new MemoryKVCache<MiUserPublickey | null>(1000 * 60 * 60 * 12); // 12h
}
@bindThis
diff --git a/packages/backend/src/server/api/AuthenticateService.ts b/packages/backend/src/server/api/AuthenticateService.ts
index ddef8db987..690ff2e022 100644
--- a/packages/backend/src/server/api/AuthenticateService.ts
+++ b/packages/backend/src/server/api/AuthenticateService.ts
@@ -37,7 +37,7 @@ export class AuthenticateService implements OnApplicationShutdown {
private cacheService: CacheService,
) {
- this.appCache = new MemoryKVCache<MiApp>(Infinity);
+ this.appCache = new MemoryKVCache<MiApp>(1000 * 60 * 60 * 24 * 7); // 1w
}
@bindThis