diff --git a/src/services/diskCache.ts b/src/services/diskCache.ts index 042d2aa02..59a7085cf 100644 --- a/src/services/diskCache.ts +++ b/src/services/diskCache.ts @@ -1,11 +1,12 @@ -import path from 'path'; -import { readFile, writeFile, existsSync, unlink } from 'promise-fs'; import DiskLRUService from '../services/diskLRU'; import crypto from 'crypto'; +import { existsSync, readFile, writeFile, unlink } from 'promise-fs'; +import path from 'path'; +import { LimitedCache } from '../types/cache'; const MAX_CACHE_SIZE = 1000 * 1000 * 1000; // 1GB -export class DiskCache { +export class DiskCache implements LimitedCache { constructor(private cacheBucketDir: string) {} async put(cacheKey: string, response: Response): Promise { diff --git a/src/types/cache.ts b/src/types/cache.ts new file mode 100644 index 000000000..a5412f0eb --- /dev/null +++ b/src/types/cache.ts @@ -0,0 +1,5 @@ +export interface LimitedCache { + match: (key: string) => Promise; + put: (key: string, data: Response) => Promise; + delete: (key: string) => Promise; +}