export class Cache<T> {
    private cache = new Set<T>();
  
    add(item: T): void {
      this.cache.add(item);
    }
  
    has(item: T): boolean {
      return this.cache.has(item);
    }
  
    remove(item: T): void {
      this.cache.delete(item);
    }
  
    clear(): void {
      this.cache.clear();
    }
  
    getAll(): T[] {
      return Array.from(this.cache);
    }

    forEach(callback: (item: T) => void): void {
        this.cache.forEach((item) => callback(item));
    }
}