import type { CacheAdapter } from './CacheAdapter' ; export class MemoryCacheAdapter implements CacheAdapter { private readonly data = new Map < string , { data : any ; expiration : number ; } > ( ) ; constructor ( private readonly options ) { } inheritdoc async get < T = any > ( name ) { const data = this . data . get ( name ) ; if ( data ) { if ( data . expiration < Date . now ( ) ) { this . data . delete ( name ) ; } else { return data . data ; } } return undefined ; } inheritdoc async set ( name , data , origin , expiration ? ) { this . data . set ( name , { data , expiration : Date . now ( ) + ( expiration ?? this . options . expiration ) } ) ; } inheritdoc async clear ( ) { this . data . clear ( ) ; } }