2020-12-04 14:52:10 +00:00
|
|
|
package caching
|
|
|
|
|
|
|
|
import (
|
|
|
|
"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 {
|
|
|
|
GetFederationQueuedPDU(eventNID int64) (event *gomatrixserverlib.HeaderedEvent, ok bool)
|
|
|
|
StoreFederationQueuedPDU(eventNID int64, event *gomatrixserverlib.HeaderedEvent)
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2021-11-24 10:45:23 +00:00
|
|
|
func (c Caches) GetFederationQueuedPDU(eventNID int64) (*gomatrixserverlib.HeaderedEvent, bool) {
|
2022-07-11 13:31:31 +00:00
|
|
|
return c.FederationPDUs.Get(eventNID)
|
2020-12-04 14:52:10 +00:00
|
|
|
}
|
|
|
|
|
2021-11-24 10:45:23 +00:00
|
|
|
func (c Caches) StoreFederationQueuedPDU(eventNID int64, event *gomatrixserverlib.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
|
|
|
}
|