forked from
pds.ls/pdsls
atproto explorer
1import { createStore } from "solid-js/store";
2
3export interface CollectionCacheEntry {
4 records: unknown[];
5 cursor: string | undefined;
6 scrollY: number;
7 reverse: boolean;
8}
9
10type RouteCache = Record<string, CollectionCacheEntry>;
11
12const [routeCache, setRouteCache] = createStore<RouteCache>({});
13
14export const getCollectionCache = (key: string): CollectionCacheEntry | undefined => {
15 return routeCache[key];
16};
17
18export const setCollectionCache = (key: string, entry: CollectionCacheEntry): void => {
19 setRouteCache(key, entry);
20};
21
22export const clearCollectionCache = (key: string): void => {
23 setRouteCache(key, undefined!);
24};