Merge branch 'add-cache-entry-delete-api' into bundle-ml-demo

This commit is contained in:
Abhinav 2023-02-10 18:09:00 +05:30
commit 34ff249b57
2 changed files with 9 additions and 3 deletions

View file

@ -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<void> {

5
src/types/cache.ts Normal file
View file

@ -0,0 +1,5 @@
export interface LimitedCache {
match: (key: string) => Promise<Response>;
put: (key: string, data: Response) => Promise<void>;
delete: (key: string) => Promise<boolean>;
}