class MemoryCachedRepository
implements Repository
A repository decorator that adds an in-memory cache layer on top of another repository. This is useful for improving performance by reducing the number of accesses to the underlying persistent storage, but it increases memory usage. The cache is not persistent and will be lost when the process exits.
Note: List operations like getMessages
and getFollowers
, and count
operations like countMessages
and countFollowers
are not cached and
always delegate to the underlying repository.
new
MemoryCachedRepository(underlying: Repository,cache?: MemoryRepository,)
Creates a new memory-cached repository.
private
cache: MemoryRepository
private
underlying: Repository
addFollowee(): Promise<void>
addFollower(): Promise<void>
addMessage(): Promise<void>
addSentFollow(): Promise<void>
countVoters(messageId: Uuid): Promise<number>
countVotes(messageId: Uuid): Promise<Readonly<Record<string, number>>>
getFollowee(followeeId: URL): Promise<Follow | undefined>
getFollowers(options?: RepositoryGetFollowersOptions): AsyncIterable<Actor>
getKeyPairs(): Promise<CryptoKeyPair[] | undefined>
getMessage(id: Uuid): Promise<>
getMessages(options?: RepositoryGetMessagesOptions): AsyncIterable<Create | Announce>
getSentFollow(id: Uuid): Promise<Follow | undefined>
hasFollower(followerId: URL): Promise<boolean>
removeFollowee(followeeId: URL): Promise<Follow | undefined>
removeFollower(): Promise<Actor | undefined>
removeMessage(id: Uuid): Promise<>
removeSentFollow(id: Uuid): Promise<Follow | undefined>
setKeyPairs(keyPairs: CryptoKeyPair[]): Promise<void>