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