summaryrefslogtreecommitdiff
path: root/packages/backend/src/core/CacheService.ts
diff options
context:
space:
mode:
authordakkar <dakkar@thenautilus.net>2024-08-06 17:51:51 +0100
committerdakkar <dakkar@thenautilus.net>2024-08-06 17:51:51 +0100
commit94dceb9e15474f85d94b7ea89a5e2197d4f9b6fc (patch)
tree6bb6da6dea6e802a5c5106a90564e11b01a31ddd /packages/backend/src/core/CacheService.ts
parentappease the linter (diff)
parentmerge: Remove infinite caches to prevent memory leak (!587) (diff)
downloadsharkey-94dceb9e15474f85d94b7ea89a5e2197d4f9b6fc.tar.gz
sharkey-94dceb9e15474f85d94b7ea89a5e2197d4f9b6fc.tar.bz2
sharkey-94dceb9e15474f85d94b7ea89a5e2197d4f9b6fc.zip
Merge branch 'develop' into feature/misskey-2024.07
Diffstat (limited to 'packages/backend/src/core/CacheService.ts')
-rw-r--r--packages/backend/src/core/CacheService.ts12
1 files changed, 6 insertions, 6 deletions
diff --git a/packages/backend/src/core/CacheService.ts b/packages/backend/src/core/CacheService.ts
index d008e7ec52..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
@@ -135,14 +135,14 @@ export class CacheService implements OnApplicationShutdown {
if (user == null) {
this.userByIdCache.delete(body.id);
this.localUserByIdCache.delete(body.id);
- for (const [k, v] of this.uriPersonCache.cache.entries()) {
+ for (const [k, v] of this.uriPersonCache.entries) {
if (v.value?.id === body.id) {
this.uriPersonCache.delete(k);
}
}
} else {
this.userByIdCache.set(user.id, user);
- for (const [k, v] of this.uriPersonCache.cache.entries()) {
+ for (const [k, v] of this.uriPersonCache.entries) {
if (v.value?.id === user.id) {
this.uriPersonCache.set(k, user);
}