@httpc/kit
Version:
httpc toolbox for building function-based API with minimal code and end-to-end type safety
40 lines (39 loc) • 897 B
JavaScript
export class WaterfallCache {
constructor(options) {
this.providers = options.providers;
}
keys() {
return this.providers[0].keys();
}
has(key) {
for (const p of this.providers) {
if (p.has(key)) {
return true;
}
}
return false;
}
get(key) {
for (const p of this.providers) {
const value = p.get(key);
if (value !== null && value !== undefined) {
return value;
}
}
}
set(key, value) {
for (const p of this.providers) {
p.set(key, value);
}
}
delete(key) {
for (const p of this.providers) {
p.delete(key);
}
}
clear() {
for (const p of this.providers) {
p.clear();
}
}
}