diff options
author | Neil Alexander <neilalexander@users.noreply.github.com> | 2020-08-25 12:32:29 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-25 12:32:29 +0100 |
commit | c8b873abc8cb20227774c648b7a774214c8f3752 (patch) | |
tree | 78e7cf34b4fc8625cc6458fead0fd2adee5114a2 /internal/caching/impl_inmemorylru.go | |
parent | 05242096a17ab432878f777c64240c2a3d5b367c (diff) |
Roomserver NID caches (#1335)
* Initial work on roomserver NID caches
* Give caches to roomserver storage
* Populate caches
* Fix bugs
* Fix WASM build
* Don't hit cache twice in RoomNIDExcludingStubs
* Store reverse room ID-room NID mapping, consult caches when assigning NIDs
Diffstat (limited to 'internal/caching/impl_inmemorylru.go')
-rw-r--r-- | internal/caching/impl_inmemorylru.go | 44 |
1 files changed, 42 insertions, 2 deletions
diff --git a/internal/caching/impl_inmemorylru.go b/internal/caching/impl_inmemorylru.go index 7bb791dd..e99c18d7 100644 --- a/internal/caching/impl_inmemorylru.go +++ b/internal/caching/impl_inmemorylru.go @@ -27,9 +27,49 @@ func NewInMemoryLRUCache(enablePrometheus bool) (*Caches, error) { if err != nil { return nil, err } + roomServerStateKeyNIDs, err := NewInMemoryLRUCachePartition( + RoomServerStateKeyNIDsCacheName, + RoomServerStateKeyNIDsCacheMutable, + RoomServerStateKeyNIDsCacheMaxEntries, + enablePrometheus, + ) + if err != nil { + return nil, err + } + roomServerEventTypeNIDs, err := NewInMemoryLRUCachePartition( + RoomServerEventTypeNIDsCacheName, + RoomServerEventTypeNIDsCacheMutable, + RoomServerEventTypeNIDsCacheMaxEntries, + enablePrometheus, + ) + if err != nil { + return nil, err + } + roomServerRoomNIDs, err := NewInMemoryLRUCachePartition( + RoomServerRoomNIDsCacheName, + RoomServerRoomNIDsCacheMutable, + RoomServerRoomNIDsCacheMaxEntries, + enablePrometheus, + ) + if err != nil { + return nil, err + } + roomServerRoomIDs, err := NewInMemoryLRUCachePartition( + RoomServerRoomIDsCacheName, + RoomServerRoomIDsCacheMutable, + RoomServerRoomIDsCacheMaxEntries, + enablePrometheus, + ) + if err != nil { + return nil, err + } return &Caches{ - RoomVersions: roomVersions, - ServerKeys: serverKeys, + RoomVersions: roomVersions, + ServerKeys: serverKeys, + RoomServerStateKeyNIDs: roomServerStateKeyNIDs, + RoomServerEventTypeNIDs: roomServerEventTypeNIDs, + RoomServerRoomNIDs: roomServerRoomNIDs, + RoomServerRoomIDs: roomServerRoomIDs, }, nil } |