feat: profile cache worker relay

This commit is contained in:
2024-01-18 22:04:11 +00:00
parent 084558b3e7
commit 6eef8c7fef
4 changed files with 111 additions and 5 deletions

View File

@ -1,4 +1,4 @@
import { RelayMetricCache, UserProfileCache, UserRelaysCache } from "@snort/system";
import { RelayMetricCache, UserRelaysCache } from "@snort/system";
import { SnortSystemDb } from "@snort/system-web";
import { WorkerRelayInterface } from "@snort/worker-relay";
import WorkerRelayPath from "@snort/worker-relay/dist/worker?worker&url";
@ -6,6 +6,7 @@ import WorkerRelayPath from "@snort/worker-relay/dist/worker?worker&url";
import { ChatCache } from "./ChatCache";
import { EventCacheWorker } from "./EventCacheWorker";
import { GiftWrapCache } from "./GiftWrapCache";
import { ProfileCacheRelayWorker } from "./ProfileWorkeCache";
export const Relay = new WorkerRelayInterface(WorkerRelayPath);
export async function initRelayWorker() {
@ -21,9 +22,10 @@ export async function initRelayWorker() {
}
export const SystemDb = new SnortSystemDb();
export const UserCache = new UserProfileCache(SystemDb.users);
export const UserRelays = new UserRelaysCache(SystemDb.userRelays);
export const RelayMetrics = new RelayMetricCache(SystemDb.relayMetrics);
export const UserCache = new ProfileCacheRelayWorker(Relay);
export const EventsCache = new EventCacheWorker(Relay);
export const Chats = new ChatCache();
@ -31,7 +33,7 @@ export const GiftsCache = new GiftWrapCache();
export async function preload(follows?: Array<string>) {
const preloads = [
UserCache.preload(follows),
UserCache.preload(),
Chats.preload(),
RelayMetrics.preload(),
GiftsCache.preload(),