From a101b3a713d229ccf218b42be8760b57d7dd9751 Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Wed, 22 Apr 2020 11:11:56 +0100 Subject: [PATCH] Define const for max cache entries --- common/caching/cache.go | 4 ++++ common/caching/inmemorylru.go | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/common/caching/cache.go b/common/caching/cache.go index 09edb44f9..83404fecf 100644 --- a/common/caching/cache.go +++ b/common/caching/cache.go @@ -2,6 +2,10 @@ package caching import "github.com/matrix-org/gomatrixserverlib" +const ( + MaxRoomVersionCacheEntries = 128 +) + type Cache interface { GetRoomVersion(roomId string) (gomatrixserverlib.RoomVersion, bool) StoreRoomVersion(roomId string, roomVersion gomatrixserverlib.RoomVersion) diff --git a/common/caching/inmemorylru.go b/common/caching/inmemorylru.go index df9295ba2..89101f4a2 100644 --- a/common/caching/inmemorylru.go +++ b/common/caching/inmemorylru.go @@ -10,7 +10,7 @@ type InMemoryLRUCache struct { } func NewInMemoryLRUCache() (*InMemoryLRUCache, error) { - roomVersionCache, rvErr := lru.New(128) + roomVersionCache, rvErr := lru.New(MaxRoomVersionCacheEntries) if rvErr != nil { return nil, rvErr }