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