improve cache api

This commit is contained in:
Sebastian Sdorra
2011-02-12 10:52:04 +01:00
parent 8cdbcb812a
commit dbb757414b
8 changed files with 36 additions and 498 deletions

View File

@@ -29,17 +29,14 @@
*
*/
package sonia.scm.cache;
//~--- non-JDK imports --------------------------------------------------------
import net.sf.ehcache.Cache;
import net.sf.ehcache.Element;
//~--- JDK imports ------------------------------------------------------------
import java.util.Collection;
/**
*
* @author Sebastian Sdorra
@@ -47,7 +44,7 @@ import java.util.Collection;
* @param <K>
* @param <V>
*/
public class EhCache<K, V> implements ExtendedCache<K, V>
public class EhCache<K, V> implements Cache<K, V>
{
/**
@@ -56,7 +53,7 @@ public class EhCache<K, V> implements ExtendedCache<K, V>
*
* @param cache
*/
public EhCache(Cache cache)
public EhCache(net.sf.ehcache.Cache cache)
{
this.cache = cache;
}
@@ -78,12 +75,13 @@ public class EhCache<K, V> implements ExtendedCache<K, V>
*
*
* @param key
* @param value
*
* @return
*/
@Override
public void put(K key, V value)
public boolean contains(K key)
{
cache.put(new Element(key, value));
return cache.get(key) != null;
}
/**
@@ -94,7 +92,7 @@ public class EhCache<K, V> implements ExtendedCache<K, V>
* @param value
*/
@Override
public void putCollection(K key, Collection<V> value)
public void put(K key, V value)
{
cache.put(new Element(key, value));
}
@@ -113,20 +111,6 @@ public class EhCache<K, V> implements ExtendedCache<K, V>
return cache.remove(key);
}
/**
* Method description
*
*
* @param key
*
* @return
*/
@Override
public boolean removeCollection(K key)
{
return cache.remove(key);
}
//~--- get methods ----------------------------------------------------------
/**
@@ -151,30 +135,8 @@ public class EhCache<K, V> implements ExtendedCache<K, V>
return value;
}
/**
* Method description
*
*
* @param key
*
* @return
*/
@Override
public Collection<V> getCollection(K key)
{
Collection<V> value = null;
Element el = cache.get(key);
if (el != null)
{
value = (Collection<V>) el.getObjectValue();
}
return value;
}
//~--- fields ---------------------------------------------------------------
/** Field description */
private Cache cache;
private net.sf.ehcache.Cache cache;
}