Documentation
¶
Index ¶
- Constants
- type Cache
- type Caches
- func (c Caches) EvictFederationQueuedEDU(eventNID int64)
- func (c Caches) EvictFederationQueuedPDU(eventNID int64)
- func (c Caches) GetFederationQueuedEDU(eventNID int64) (*gomatrixserverlib.EDU, bool)
- func (c Caches) GetFederationQueuedPDU(eventNID int64) (*gomatrixserverlib.HeaderedEvent, bool)
- func (c Caches) GetRoomInfo(roomID string) (types.RoomInfo, bool)
- func (c Caches) GetRoomServerRoomID(roomNID types.RoomNID) (string, bool)
- func (c Caches) GetRoomVersion(roomID string) (gomatrixserverlib.RoomVersion, bool)
- func (c Caches) GetServerKey(request gomatrixserverlib.PublicKeyLookupRequest, ...) (gomatrixserverlib.PublicKeyLookupResult, bool)
- func (c Caches) GetSpaceSummary(roomID string) (r gomatrixserverlib.MSC2946SpacesResponse, ok bool)
- func (c Caches) IsLazyLoadedUserCached(device *userapi.Device, roomID, userID string) (string, bool)
- func (c Caches) StoreFederationQueuedEDU(eventNID int64, event *gomatrixserverlib.EDU)
- func (c Caches) StoreFederationQueuedPDU(eventNID int64, event *gomatrixserverlib.HeaderedEvent)
- func (c Caches) StoreLazyLoadedUser(device *userapi.Device, roomID, userID, eventID string)
- func (c Caches) StoreRoomInfo(roomID string, roomInfo types.RoomInfo)
- func (c Caches) StoreRoomServerRoomID(roomNID types.RoomNID, roomID string)
- func (c Caches) StoreRoomVersion(roomID string, roomVersion gomatrixserverlib.RoomVersion)
- func (c Caches) StoreServerKey(request gomatrixserverlib.PublicKeyLookupRequest, ...)
- func (c Caches) StoreSpaceSummary(roomID string, r gomatrixserverlib.MSC2946SpacesResponse)
- type EDUCache
- func (t *EDUCache) AddTypingUser(userID, roomID string, expire *time.Time) int64
- func (t *EDUCache) GetLatestSyncPosition() int64
- func (t *EDUCache) GetTypingUsers(roomID string) []string
- func (t *EDUCache) GetTypingUsersIfUpdatedAfter(roomID string, position int64) (users []string, updated bool)
- func (t *EDUCache) RemoveUser(userID, roomID string) int64
- func (t *EDUCache) SetTimeoutCallback(fn TimeoutCallbackFn)
- type FederationCache
- type InMemoryLRUCachePartition
- type LazyLoadCache
- type RoomInfoCache
- type RoomServerCaches
- type RoomServerNIDsCache
- type RoomVersionCache
- type ServerKeyCache
- type SpaceSummaryRoomsCache
- type TimeoutCallbackFn
Constants ¶
const ( FederationEventCacheName = "federation_event" FederationEventCacheMaxEntries = 256 FederationEventCacheMutable = true // to allow use of Unset only FederationEventCacheMaxAge = CacheNoMaxAge )
const ( LazyLoadCacheName = "lazy_load_members" LazyLoadCacheMaxEntries = 128 LazyLoadCacheMaxUserEntries = 128 LazyLoadCacheMutable = true LazyLoadCacheMaxAge = time.Minute * 30 )
const ( RoomInfoCacheName = "roominfo" RoomInfoCacheMaxEntries = 1024 RoomInfoCacheMutable = true RoomInfoCacheMaxAge = time.Minute * 5 )
const ( RoomServerRoomIDsCacheName = "roomserver_room_ids" RoomServerRoomIDsCacheMaxEntries = 1024 RoomServerRoomIDsCacheMutable = false RoomServerRoomIDsCacheMaxAge = CacheNoMaxAge )
const ( RoomVersionCacheName = "room_versions" RoomVersionCacheMaxEntries = 1024 RoomVersionCacheMutable = false RoomVersionCacheMaxAge = CacheNoMaxAge )
const ( ServerKeyCacheName = "server_key" ServerKeyCacheMaxEntries = 4096 ServerKeyCacheMutable = true ServerKeyCacheMaxAge = CacheNoMaxAge )
const ( SpaceSummaryRoomsCacheName = "space_summary_rooms" SpaceSummaryRoomsCacheMaxEntries = 100 SpaceSummaryRoomsCacheMutable = true SpaceSummaryRoomsCacheMaxAge = time.Minute * 5 )
const CacheNoMaxAge = time.Duration(0)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache interface { Get(key string) (value interface{}, ok bool) Set(key string, value interface{}) Unset(key string) }
Cache is the interface that an implementation must satisfy.
type Caches ¶
type Caches struct { RoomVersions Cache // RoomVersionCache ServerKeys Cache // ServerKeyCache RoomServerRoomNIDs Cache // RoomServerNIDsCache RoomServerRoomIDs Cache // RoomServerNIDsCache RoomInfos Cache // RoomInfoCache FederationEvents Cache // FederationEventsCache SpaceSummaryRooms Cache // SpaceSummaryRoomsCache LazyLoading Cache // LazyLoadCache }
Caches contains a set of references to caches. They may be different implementations as long as they satisfy the Cache interface.
func NewInMemoryLRUCache ¶
func (Caches) EvictFederationQueuedEDU ¶ added in v0.6.0
func (Caches) EvictFederationQueuedPDU ¶ added in v0.6.0
func (Caches) GetFederationQueuedEDU ¶ added in v0.6.0
func (c Caches) GetFederationQueuedEDU(eventNID int64) (*gomatrixserverlib.EDU, bool)
func (Caches) GetFederationQueuedPDU ¶ added in v0.6.0
func (c Caches) GetFederationQueuedPDU(eventNID int64) (*gomatrixserverlib.HeaderedEvent, bool)
func (Caches) GetRoomInfo ¶ added in v0.3.4
GetRoomInfo must only be called from the roomserver only. It is not safe for use from other components.
func (Caches) GetRoomServerRoomID ¶
func (Caches) GetRoomVersion ¶
func (c Caches) GetRoomVersion(roomID string) (gomatrixserverlib.RoomVersion, bool)
func (Caches) GetServerKey ¶
func (c Caches) GetServerKey( request gomatrixserverlib.PublicKeyLookupRequest, timestamp gomatrixserverlib.Timestamp, ) (gomatrixserverlib.PublicKeyLookupResult, bool)
func (Caches) GetSpaceSummary ¶ added in v0.6.5
func (c Caches) GetSpaceSummary(roomID string) (r gomatrixserverlib.MSC2946SpacesResponse, ok bool)
func (Caches) IsLazyLoadedUserCached ¶ added in v0.8.3
func (Caches) StoreFederationQueuedEDU ¶ added in v0.6.0
func (c Caches) StoreFederationQueuedEDU(eventNID int64, event *gomatrixserverlib.EDU)
func (Caches) StoreFederationQueuedPDU ¶ added in v0.6.0
func (c Caches) StoreFederationQueuedPDU(eventNID int64, event *gomatrixserverlib.HeaderedEvent)
func (Caches) StoreLazyLoadedUser ¶ added in v0.8.3
func (Caches) StoreRoomInfo ¶ added in v0.3.4
StoreRoomInfo must only be called from the roomserver only. It is not safe for use from other components.
func (Caches) StoreRoomServerRoomID ¶
func (Caches) StoreRoomVersion ¶
func (c Caches) StoreRoomVersion(roomID string, roomVersion gomatrixserverlib.RoomVersion)
func (Caches) StoreServerKey ¶
func (c Caches) StoreServerKey( request gomatrixserverlib.PublicKeyLookupRequest, response gomatrixserverlib.PublicKeyLookupResult, )
func (Caches) StoreSpaceSummary ¶ added in v0.6.5
func (c Caches) StoreSpaceSummary(roomID string, r gomatrixserverlib.MSC2946SpacesResponse)
type EDUCache ¶ added in v0.8.0
EDUCache maintains a list of users typing in each room.
func NewTypingCache ¶ added in v0.8.0
func NewTypingCache() *EDUCache
NewTypingCache returns a new EDUCache initialised for use.
func (*EDUCache) AddTypingUser ¶ added in v0.8.0
AddTypingUser sets an user as typing in a room. expire is the time when the user typing should time out. if expire is nil, defaultTypingTimeout is assumed. Returns the latest sync position for typing after update.
func (*EDUCache) GetLatestSyncPosition ¶ added in v0.8.0
func (*EDUCache) GetTypingUsers ¶ added in v0.8.0
GetTypingUsers returns the list of users typing in a room.
func (*EDUCache) GetTypingUsersIfUpdatedAfter ¶ added in v0.8.0
func (t *EDUCache) GetTypingUsersIfUpdatedAfter( roomID string, position int64, ) (users []string, updated bool)
GetTypingUsersIfUpdatedAfter returns all users typing in this room with updated == true if the typing sync position of the room is after the given position. Otherwise, returns an empty slice with updated == false.
func (*EDUCache) RemoveUser ¶ added in v0.8.0
RemoveUser with mutex lock & stop the timer. Returns the latest sync position for typing after update.
func (*EDUCache) SetTimeoutCallback ¶ added in v0.8.0
func (t *EDUCache) SetTimeoutCallback(fn TimeoutCallbackFn)
SetTimeoutCallback sets a callback function that is called right after a user is removed from the typing user list due to timeout.
type FederationCache ¶ added in v0.6.0
type FederationCache interface { GetFederationQueuedPDU(eventNID int64) (event *gomatrixserverlib.HeaderedEvent, ok bool) StoreFederationQueuedPDU(eventNID int64, event *gomatrixserverlib.HeaderedEvent) EvictFederationQueuedPDU(eventNID int64) GetFederationQueuedEDU(eventNID int64) (event *gomatrixserverlib.EDU, ok bool) StoreFederationQueuedEDU(eventNID int64, event *gomatrixserverlib.EDU) EvictFederationQueuedEDU(eventNID int64) }
FederationCache contains the subset of functions needed for a federation event cache.
type InMemoryLRUCachePartition ¶
type InMemoryLRUCachePartition struct {
// contains filtered or unexported fields
}
func (*InMemoryLRUCachePartition) Get ¶
func (c *InMemoryLRUCachePartition) Get(key string) (value interface{}, ok bool)
func (*InMemoryLRUCachePartition) Set ¶
func (c *InMemoryLRUCachePartition) Set(key string, value interface{})
func (*InMemoryLRUCachePartition) Unset ¶
func (c *InMemoryLRUCachePartition) Unset(key string)
type LazyLoadCache ¶ added in v0.8.2
type RoomInfoCache ¶ added in v0.3.4
type RoomInfoCache interface { GetRoomInfo(roomID string) (roomInfo types.RoomInfo, ok bool) StoreRoomInfo(roomID string, roomInfo types.RoomInfo) }
RoomInfosCache contains the subset of functions needed for a room Info cache. It must only be used from the roomserver only It is not safe for use from other components.
type RoomServerCaches ¶
type RoomServerCaches interface { RoomServerNIDsCache RoomVersionCache RoomInfoCache }
type RoomServerNIDsCache ¶
type RoomServerNIDsCache interface { GetRoomServerRoomID(roomNID types.RoomNID) (string, bool) StoreRoomServerRoomID(roomNID types.RoomNID, roomID string) }
RoomServerNIDsCache contains the subset of functions needed for a roomserver NID cache.
type RoomVersionCache ¶
type RoomVersionCache interface { GetRoomVersion(roomID string) (roomVersion gomatrixserverlib.RoomVersion, ok bool) StoreRoomVersion(roomID string, roomVersion gomatrixserverlib.RoomVersion) }
RoomVersionsCache contains the subset of functions needed for a room version cache.
type ServerKeyCache ¶
type ServerKeyCache interface { // request -> timestamp is emulating gomatrixserverlib.FetchKeys: // https://github.com/matrix-org/gomatrixserverlib/blob/f69539c86ea55d1e2cc76fd8e944e2d82d30397c/keyring.go#L95 // The timestamp should be the timestamp of the event that is being // verified. We will not return keys from the cache that are not valid // at this timestamp. GetServerKey(request gomatrixserverlib.PublicKeyLookupRequest, timestamp gomatrixserverlib.Timestamp) (response gomatrixserverlib.PublicKeyLookupResult, ok bool) // request -> result is emulating gomatrixserverlib.StoreKeys: // https://github.com/matrix-org/gomatrixserverlib/blob/f69539c86ea55d1e2cc76fd8e944e2d82d30397c/keyring.go#L112 StoreServerKey(request gomatrixserverlib.PublicKeyLookupRequest, response gomatrixserverlib.PublicKeyLookupResult) }
ServerKeyCache contains the subset of functions needed for a server key cache.
type SpaceSummaryRoomsCache ¶ added in v0.6.5
type SpaceSummaryRoomsCache interface { GetSpaceSummary(roomID string) (r gomatrixserverlib.MSC2946SpacesResponse, ok bool) StoreSpaceSummary(roomID string, r gomatrixserverlib.MSC2946SpacesResponse) }
type TimeoutCallbackFn ¶ added in v0.8.0
TimeoutCallbackFn is a function called right after the removal of a user from the typing user list due to timeout. latestSyncPosition is the typing sync position after the removal.