Refactor StoreEvent and create a new RoomDatabase interface (#2985)
This PR changes a few things: - It pulls out the creation of several NIDs from the `StoreEvent` function to make the functions more reusable - Uses more caching when using those NIDs to avoid DB round trips
This commit is contained in:
parent
e6aa0955ff
commit
ad07b169b8
31 changed files with 459 additions and 302 deletions
|
|
@ -40,6 +40,9 @@ const (
|
|||
spaceSummaryRoomsCache
|
||||
lazyLoadingCache
|
||||
eventStateKeyCache
|
||||
eventTypeCache
|
||||
eventTypeNIDCache
|
||||
eventStateKeyNIDCache
|
||||
)
|
||||
|
||||
func NewRistrettoCache(maxCost config.DataUnit, maxAge time.Duration, enablePrometheus bool) *Caches {
|
||||
|
|
@ -105,6 +108,21 @@ func NewRistrettoCache(maxCost config.DataUnit, maxAge time.Duration, enableProm
|
|||
Prefix: eventStateKeyCache,
|
||||
MaxAge: maxAge,
|
||||
},
|
||||
RoomServerStateKeyNIDs: &RistrettoCachePartition[string, types.EventStateKeyNID]{ // eventStateKey -> eventStateKey NID
|
||||
cache: cache,
|
||||
Prefix: eventStateKeyNIDCache,
|
||||
MaxAge: maxAge,
|
||||
},
|
||||
RoomServerEventTypeNIDs: &RistrettoCachePartition[string, types.EventTypeNID]{ // eventType -> eventType NID
|
||||
cache: cache,
|
||||
Prefix: eventTypeCache,
|
||||
MaxAge: maxAge,
|
||||
},
|
||||
RoomServerEventTypes: &RistrettoCachePartition[types.EventTypeNID, string]{ // eventType NID -> eventType
|
||||
cache: cache,
|
||||
Prefix: eventTypeNIDCache,
|
||||
MaxAge: maxAge,
|
||||
},
|
||||
FederationPDUs: &RistrettoCostedCachePartition[int64, *gomatrixserverlib.HeaderedEvent]{ // queue NID -> PDU
|
||||
&RistrettoCachePartition[int64, *gomatrixserverlib.HeaderedEvent]{
|
||||
cache: cache,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue