2020-12-04 08:52:10 -06:00
|
|
|
package caching
|
|
|
|
|
|
|
|
import (
|
2023-04-27 06:54:20 -05:00
|
|
|
"github.com/matrix-org/dendrite/roomserver/types"
|
2020-12-04 08:52:10 -06:00
|
|
|
"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 {
|
2023-04-27 06:54:20 -05:00
|
|
|
GetFederationQueuedPDU(eventNID int64) (event *types.HeaderedEvent, ok bool)
|
|
|
|
StoreFederationQueuedPDU(eventNID int64, event *types.HeaderedEvent)
|
2021-11-24 04:45:23 -06:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2023-04-27 06:54:20 -05:00
|
|
|
func (c Caches) GetFederationQueuedPDU(eventNID int64) (*types.HeaderedEvent, bool) {
|
2022-07-11 08:31:31 -05:00
|
|
|
return c.FederationPDUs.Get(eventNID)
|
2020-12-04 08:52:10 -06:00
|
|
|
}
|
|
|
|
|
2023-04-27 06:54:20 -05:00
|
|
|
func (c Caches) StoreFederationQueuedPDU(eventNID int64, event *types.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
|
|
|
}
|