mirror of
https://github.com/matrix-org/dendrite.git
synced 2026-01-07 06:03:09 -06:00
Clean up a bit
This commit is contained in:
parent
ad40b054bc
commit
03cd7f041b
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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")
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue