All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.venky.cache.UnboundedCache Maven / Gradle / Ivy

There is a newer version: 1.18
Show newest version
package com.venky.cache;

import java.util.HashMap;

public abstract class UnboundedCache extends HashMap{

	/**
	 * 
	 */
	private static final long serialVersionUID = -279156550678934353L;
	@SuppressWarnings("unchecked")
	public V get(Object key){
		K k = (K)key;
		V v = super.get(k);
		if (v == null && !containsKey(k)){
			synchronized (this) {
				v = super.get(k);
				if (v == null && !containsKey(k)){
					v = getValue(k);
					super.put(k, v);
				}
			}
		}
		return v;
	}
	
	protected abstract V getValue(K key);
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy