@linkedmink/multilevel-aging-cache
Version:
Package provides an interface to cache and persist data to Redis, MongoDB, memory
20 lines (17 loc) • 690 B
text/typescript
import { IAgingCacheDeleteStrategy } from './IAgingCacheWriteStrategy';
import { IAgingCacheWrite } from './IAgingCache';
import { AgingCacheWriteStrategy } from './AgingCacheWriteStrategy';
/**
* Strategy to overwrite regardless of the higher level value
*/
export class OverwriteAlwaysDeleteStrategy<TKey, TValue>
extends AgingCacheWriteStrategy<TKey, TValue>
implements IAgingCacheDeleteStrategy<TKey, TValue>
{
delete(key: TKey, _force: boolean): Promise<IAgingCacheWrite<TValue>> {
return this.executeDelete(key);
}
evict(key: TKey, evictAtLevel?: number, _force?: boolean): Promise<IAgingCacheWrite<TValue>> {
return this.executeDelete(key, evictAtLevel);
}
}