diff --git a/internal/caching/cache_lazy_load_members.go b/internal/caching/cache_lazy_load_members.go index 42f469720..37c1802cb 100644 --- a/internal/caching/cache_lazy_load_members.go +++ b/internal/caching/cache_lazy_load_members.go @@ -1,19 +1,9 @@ package caching import ( - "time" - userapi "github.com/matrix-org/dendrite/userapi/api" ) -const ( - LazyLoadCacheName = "lazy_load_members" - LazyLoadCacheMaxEntries = 128 - LazyLoadCacheMaxUserEntries = 128 - LazyLoadCacheMutable = true - LazyLoadCacheMaxAge = time.Minute * 30 -) - type LazyLoadCache interface { StoreLazyLoadedUser(device *userapi.Device, roomID, userID, eventID string) IsLazyLoadedUserCached(device *userapi.Device, roomID, userID string) (string, bool) diff --git a/internal/caching/cache_roomservernids.go b/internal/caching/cache_roomservernids.go index dcdf8c970..b409aeef2 100644 --- a/internal/caching/cache_roomservernids.go +++ b/internal/caching/cache_roomservernids.go @@ -4,13 +4,6 @@ import ( "github.com/matrix-org/dendrite/roomserver/types" ) -const ( - RoomServerRoomIDsCacheName = "roomserver_room_ids" - RoomServerRoomIDsCacheMaxEntries = 1024 - RoomServerRoomIDsCacheMutable = false - RoomServerRoomIDsCacheMaxAge = CacheNoMaxAge -) - type RoomServerCaches interface { RoomServerNIDsCache RoomVersionCache diff --git a/internal/caching/impl_ristretto.go b/internal/caching/impl_ristretto.go index c9ea84a21..48c2f9880 100644 --- a/internal/caching/impl_ristretto.go +++ b/internal/caching/impl_ristretto.go @@ -119,6 +119,15 @@ func NewRistrettoCache(maxCost CacheSize, enablePrometheus bool) (*Caches, error }, nil } +type RistrettoCostedCachePartition[k keyable, v costable] struct { + *RistrettoCachePartition[k, v] +} + +func (c *RistrettoCostedCachePartition[K, V]) Set(key K, value V) { + cost := value.CacheCost() + c.setWithCost(key, value, int64(cost)) +} + type RistrettoCachePartition[K keyable, V any] struct { cache *ristretto.Cache Prefix byte @@ -164,12 +173,3 @@ func (c *RistrettoCachePartition[K, V]) Get(key K) (value V, ok bool) { value, ok = v.(V) return } - -type RistrettoCostedCachePartition[k keyable, v costable] struct { - *RistrettoCachePartition[k, v] -} - -func (c *RistrettoCostedCachePartition[K, V]) Set(key K, value V) { - cost := value.CacheCost() - c.setWithCost(key, value, int64(cost)) -} diff --git a/setup/base/base.go b/setup/base/base.go index 5cc90b46c..9265f9719 100644 --- a/setup/base/base.go +++ b/setup/base/base.go @@ -161,7 +161,7 @@ func NewBaseDendrite(cfg *config.Dendrite, componentName string, options ...Base } } - cache, err := caching.NewRistrettoCache(1*caching.GB, enableMetrics) + cache, err := caching.NewRistrettoCache(caching.MB*64, enableMetrics) if err != nil { logrus.WithError(err).Warnf("Failed to create cache") }