LRU cache for room versions in RS query API (#976)

* Experimental LRU cache for room versions

* Don't accidentally try to type-assert nil

* Also reduce hits on query API

* Use hashicorp implementation which mutexes for us

* Define const for max cache entries

* Rename to be specifically immutable, panic if we try to mutate a cache entry

* Review comments

* Remove nil guards, give roomserver integration test a cache

* go mod tidy
This commit is contained in:
Neil Alexander 2020-04-22 13:00:05 +01:00 committed by GitHub
parent 71f9d35b7c
commit a466e9e9cc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 112 additions and 22 deletions

View file

@ -0,0 +1,12 @@
package caching
import "github.com/matrix-org/gomatrixserverlib"
const (
RoomVersionMaxCacheEntries = 128
)
type ImmutableCache interface {
GetRoomVersion(roomId string) (gomatrixserverlib.RoomVersion, bool)
StoreRoomVersion(roomId string, roomVersion gomatrixserverlib.RoomVersion)
}