import LRU from 'lru-cache' ; import { PageCache , PageCachesInterface } from '../type' ; export class LRUCaches implements PageCachesInterface { caches : LRU < string , PageCache > ; private readonly max : number ; constructor ( options ) { this . max = options . max ; this . caches = new LRU ( this . max ) ; } init ( ) { return Promise . resolve ( ) ; } public keys ( ) { return this . caches . keys ( ) ; } public get ( key ) { return Promise . resolve ( this . caches . get ( key ) || null ) ; } public peek ( key ) { return this . caches . peek ( key ) || null ; } public set ( key , cache ) { this . caches . set ( key , cache ) ; return Promise . resolve ( ) ; } public del ( key ) { this . caches . del ( key ) ; } }