2020-12-04 14:52:10 +00:00
|
|
|
package caching
|
|
|
|
|
|
|
|
import (
|
2023-04-27 11:54:20 +00:00
|
|
|
"github.com/matrix-org/dendrite/roomserver/types"
|
2020-12-04 14:52:10 +00:00
|
|
|
"github.com/matrix-org/gomatrixserverlib"
|
|
|
|
)
|
|
|
|
|
2021-11-24 10:45:23 +00:00
|
|
|
// FederationCache contains the subset of functions needed for
|
2020-12-04 14:52:10 +00:00
|
|
|
// a federation event cache.
|
2021-11-24 10:45:23 +00:00
|
|
|
type FederationCache interface {
|
2023-04-27 11:54:20 +00:00
|
|
|
GetFederationQueuedPDU(eventNID int64) (event *types.HeaderedEvent, ok bool)
|
|
|
|
StoreFederationQueuedPDU(eventNID int64, event *types.HeaderedEvent)
|
2021-11-24 10:45:23 +00:00
|
|
|
EvictFederationQueuedPDU(eventNID int64)
|
2020-12-04 14:52:10 +00:00
|
|
|
|
2021-11-24 10:45:23 +00:00
|
|
|
GetFederationQueuedEDU(eventNID int64) (event *gomatrixserverlib.EDU, ok bool)
|
|
|
|
StoreFederationQueuedEDU(eventNID int64, event *gomatrixserverlib.EDU)
|
|
|
|
EvictFederationQueuedEDU(eventNID int64)
|
2020-12-04 14:52:10 +00:00
|
|
|
}
|
|
|
|
|
2023-04-27 11:54:20 +00:00
|
|
|
func (c Caches) GetFederationQueuedPDU(eventNID int64) (*types.HeaderedEvent, bool) {
|
2022-07-11 13:31:31 +00:00
|
|
|
return c.FederationPDUs.Get(eventNID)
|
2020-12-04 14:52:10 +00:00
|
|
|
}
|
|
|
|
|
2023-04-27 11:54:20 +00:00
|
|
|
func (c Caches) StoreFederationQueuedPDU(eventNID int64, event *types.HeaderedEvent) {
|
2022-07-11 13:31:31 +00:00
|
|
|
c.FederationPDUs.Set(eventNID, event)
|
2020-12-04 14:52:10 +00:00
|
|
|
}
|
|
|
|
|
2021-11-24 10:45:23 +00:00
|
|
|
func (c Caches) EvictFederationQueuedPDU(eventNID int64) {
|
2022-07-11 13:31:31 +00:00
|
|
|
c.FederationPDUs.Unset(eventNID)
|
2020-12-04 14:52:10 +00:00
|
|
|
}
|
|
|
|
|
2021-11-24 10:45:23 +00:00
|
|
|
func (c Caches) GetFederationQueuedEDU(eventNID int64) (*gomatrixserverlib.EDU, bool) {
|
2022-07-11 13:31:31 +00:00
|
|
|
return c.FederationEDUs.Get(eventNID)
|
2020-12-04 14:52:10 +00:00
|
|
|
}
|
|
|
|
|
2021-11-24 10:45:23 +00:00
|
|
|
func (c Caches) StoreFederationQueuedEDU(eventNID int64, event *gomatrixserverlib.EDU) {
|
2022-07-11 13:31:31 +00:00
|
|
|
c.FederationEDUs.Set(eventNID, event)
|
2020-12-04 14:52:10 +00:00
|
|
|
}
|
|
|
|
|
2021-11-24 10:45:23 +00:00
|
|
|
func (c Caches) EvictFederationQueuedEDU(eventNID int64) {
|
2022-07-11 13:31:31 +00:00
|
|
|
c.FederationEDUs.Unset(eventNID)
|
2020-12-04 14:52:10 +00:00
|
|
|
}
|