package w8.W88; import java.util.concurrent.ConcurrentHashMap; public class Cache { private ConcurrentHashMap cache; private long defaultTTL; public Cache() { this.cache = new ConcurrentHashMap<>(); this.defaultTTL = 60000; } public Cache(long ttlMillis) { this.cache = new ConcurrentHashMap<>(); this.defaultTTL = ttlMillis; } public void put(K key, V value) { if (key == null) { System.out.println("Error: Key cannot be null"); return; } cache.put(key, value); System.out.println("Cache put: " + key + " = " + value); } public V get(K key) { if (key == null) { System.out.println("Error: Key cannot be null"); return null; } V value = cache.get(key); if (value == null) { System.out.println("Cache miss: " + key + " not found"); return null; } System.out.println("Cache hit: " + key + " = " + value); return value; } public void remove(K key) { cache.remove(key); System.out.println("Cache removed: " + key); } public void clear() { cache.clear(); System.out.println("Cache cleared"); } public int size() { return cache.size(); } public boolean containsKey(K key) { return cache.containsKey(key); } }