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