@didomi/iabtcf-cmpapi
Version:
Ensures other in-page digital marketing technologies have access to CMP transparency and consent information for the iab. Transparency and Consent Framework (TCF).
27 lines (26 loc) • 692 B
JavaScript
import { CacheBucket } from './CacheBucket.js';
export class Cache {
cacheBuckets;
constructor() {
this.cacheBuckets = new Map();
}
getBucket(bucketName) {
let bucket = this.cacheBuckets.get(bucketName);
if (!bucket) {
bucket = new CacheBucket(bucketName);
this.cacheBuckets.set(bucketName, bucket);
}
return bucket;
}
clear() {
this.cacheBuckets.forEach((bucket) => bucket.clear());
}
numberOfBuckets() {
return this.cacheBuckets.size;
}
size() {
let total = 0;
this.cacheBuckets.forEach((bucket) => total += bucket.size());
return total;
}
}