public synchronized void put(KeyType key, ValueType value) { if (key == null) { throw new IllegalArgumentException("Cache entry key cannot be null"); } CacheEntry<KeyType, ValueType> cacheEntry = new CacheEntry<KeyType, ValueType>(key, value); cacheMap.put(cacheEntry.getKey(), cacheEntry); }
public ValueType get(KeyType key) { if (key == null) { throw new IllegalArgumentException("Key cannot be null"); } CacheEntry<KeyType, ValueType> result = cacheMap.get(key); if (result != null) { statMgr.increment(StatisticType.CACHE_HIT_COUNT, name); return result.getValue(); } else { statMgr.increment(StatisticType.CACHE_MISS_COUNT, name); return null; } }
public ValueType get(KeyType key) { if (key == null) { throw new IllegalArgumentException("Key cannot be null"); } CacheEntry<KeyType, ValueType> result = cacheMap.get(key); if (result != null) { statMgr.increment(StatisticType.CACHE_HIT_COUNT, name); return result.getValue(); } else { statMgr.increment(StatisticType.CACHE_MISS_COUNT, name); return null; } }
public synchronized void put(KeyType key, ValueType value) { if (key == null) { throw new IllegalArgumentException("Cache entry key cannot be null"); } CacheEntry<KeyType, ValueType> cacheEntry = new CacheEntry<KeyType, ValueType>(key, value); cacheMap.put(cacheEntry.getKey(), cacheEntry); }
public void addEntries(Collection<CacheEntry<KeyType, ValueType>> entries) { for (CacheEntry<KeyType, ValueType> entry : entries) { cacheMap.put(entry.getKey(), entry); } }
public void addEntries(Collection<CacheEntry<KeyType, ValueType>> entries) { for (CacheEntry<KeyType, ValueType> entry : entries) { cacheMap.put(entry.getKey(), entry); } }