|
| 1 | +declare module 'caching/cache' { |
| 2 | + export interface cacheValue { |
| 3 | + value: any; |
| 4 | + expire: number; |
| 5 | + } |
| 6 | + export type cacheEntries = { |
| 7 | + [key: string]: cacheValue; |
| 8 | + }; |
| 9 | + export abstract class Cache { |
| 10 | + abstract set<T>(key: string, value: T, durationMS?: number): void; |
| 11 | + abstract get<T>(key: string): T; |
| 12 | + abstract remove(key: string): void; |
| 13 | + } |
| 14 | + |
| 15 | +} |
| 16 | +declare module 'caching/helpers' { |
| 17 | + import { cacheValue } from 'caching/cache'; |
| 18 | + export function isExpired(val: cacheValue): boolean; |
| 19 | + export function cacheFor(n: number): { |
| 20 | + minutes: number; |
| 21 | + seconds: number; |
| 22 | + hours: number; |
| 23 | + }; |
| 24 | + |
| 25 | +} |
| 26 | +declare module 'caching/memory-cache' { |
| 27 | + import { Cache } from 'caching/cache'; |
| 28 | + export class MemoryCache implements Cache { |
| 29 | + private cache; |
| 30 | + set<T>(key: string, value: T, durationMS?: any): void; |
| 31 | + get<T>(key: string): T; |
| 32 | + remove(key: string): void; |
| 33 | + } |
| 34 | + |
| 35 | +} |
| 36 | +declare module 'caching/cookie-cache' { |
| 37 | + import { Cache } from 'caching/cache'; |
| 38 | + export class CookieCache implements Cache { |
| 39 | + private CookieName; |
| 40 | + constructor(CookieName?: string); |
| 41 | + set<T>(key: string, value: T, durationMS?: any): void; |
| 42 | + get<T>(key: string): T; |
| 43 | + remove(key: string): void; |
| 44 | + private getCacheEntries(); |
| 45 | + private setCacheEntries(entries); |
| 46 | + } |
| 47 | + |
| 48 | +} |
| 49 | +declare module 'caching/local-storage-cache' { |
| 50 | + import { Cache } from 'caching/cache'; |
| 51 | + export class LocalStorageCache implements Cache { |
| 52 | + set<T>(key: string, value: T, durationMS?: number): void; |
| 53 | + get<T>(key: string): T; |
| 54 | + remove(key: string): void; |
| 55 | + } |
| 56 | + |
| 57 | +} |
| 58 | +declare module 'caching/scoped-cache' { |
| 59 | + import { Cache } from 'caching/cache'; |
| 60 | + export class ScopedCache implements Cache { |
| 61 | + private scope; |
| 62 | + private cache; |
| 63 | + constructor(scope: string, cache: Cache); |
| 64 | + setScope(scope: string): void; |
| 65 | + set<T>(key: string, value: T, durationMS?: any): void; |
| 66 | + get<T>(key: string): T; |
| 67 | + remove(key: string): void; |
| 68 | + } |
| 69 | + |
| 70 | +} |
| 71 | +declare module 'caching' { |
| 72 | + export { Cache } from 'caching/cache'; |
| 73 | + export { cacheFor } from 'caching/helpers'; |
| 74 | + export { MemoryCache } from 'caching/memory-cache'; |
| 75 | + export { CookieCache } from 'caching/cookie-cache'; |
| 76 | + export { LocalStorageCache } from 'caching/local-storage-cache'; |
| 77 | + export { ScopedCache } from 'caching/scoped-cache'; |
| 78 | + |
| 79 | +} |
0 commit comments