public DozerCache(final String name, final int maximumSize) { if (maximumSize < 1) { throw new IllegalArgumentException("Dozer cache max size must be greater than 0"); } this.name = name; this.cacheMap = new LRUMap(maximumSize); // TODO This should be in // Collections.synchronizedMap() }
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 boolean containsKey(KeyType key) { return cacheMap.containsKey(key); }
public void clear() { cacheMap.clear(); }
public Collection<CacheEntry<KeyType, ValueType>> getEntries() { return cacheMap.values(); }
public Set<KeyType> keySet() { return cacheMap.keySet(); }
public long getSize() { return cacheMap.size(); }
public Collection<CacheEntry<KeyType, ValueType>> getEntries() { return cacheMap.values(); }
public Set<KeyType> keySet() { return cacheMap.keySet(); }
public long getSize() { return cacheMap.size(); }
public boolean containsKey(KeyType key) { return cacheMap.containsKey(key); }
public void clear() { cacheMap.clear(); }
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 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); } }
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 DozerCache(final String name, final int maximumSize) { if (maximumSize < 1) { throw new IllegalArgumentException("Dozer cache max size must be greater than 0"); } this.name = name; this.cacheMap = new LRUMap(maximumSize); // TODO This should be in Collections.synchronizedMap() }