UNPKG

1.37 kBTypeScriptView Raw
1import { ICache } from "./icache";
2/**
3 * Saves data in new cache folder or reads it from old one.
4 * Avoids perpetually growing cache and situations when things need to consider changed and then reverted data to be changed.
5 */
6export declare class RollingCache<DataType> implements ICache<DataType> {
7 private cacheRoot;
8 private checkNewCache;
9 private oldCacheRoot;
10 private newCacheRoot;
11 private rolled;
12 /**
13 * @param cacheRoot: root folder for the cache
14 * @param checkNewCache: whether to also look in new cache when reading from cache
15 */
16 constructor(cacheRoot: string, checkNewCache: boolean);
17 /**
18 * @returns true if name exist in old cache (or either old of new cache if checkNewCache is true)
19 */
20 exists(name: string): boolean;
21 path(name: string): string;
22 /**
23 * @returns true if old cache contains all names and nothing more
24 */
25 match(names: string[]): boolean;
26 /**
27 * @returns data for name, must exist in old cache (or either old of new cache if checkNewCache is true)
28 */
29 read(name: string): DataType | null | undefined;
30 write(name: string, data: DataType): void;
31 touch(name: string): void;
32 /**
33 * clears old cache and moves new in its place
34 */
35 roll(): void;
36}
37//# sourceMappingURL=rollingcache.d.ts.map
\No newline at end of file