Added get(key, type) method to Cache interface

This new get variant not only allows for generically specifying the required value type; it also skips the ValueWrapper that the standard get method returns. Note that it is not possible to differentiate between non-existing cache entries and cached null values that way; for that purpose, the standard get variant needs to be used.

Issue: SPR-11061
This commit is contained in:
Juergen Hoeller
2013-11-04 14:31:41 +01:00
parent b093b84954
commit 50d3f71923
9 changed files with 81 additions and 14 deletions

View File

@@ -20,7 +20,6 @@ import net.sf.ehcache.CacheManager;
import net.sf.ehcache.Ehcache;
import net.sf.ehcache.Element;
import net.sf.ehcache.config.CacheConfiguration;
import org.junit.Before;
import org.junit.Test;
@@ -74,6 +73,9 @@ public class EhCacheCacheTests {
assertNull(cache.get(key));
cache.put(key, value);
assertEquals(value, cache.get(key).get());
assertEquals(value, cache.get(key, String.class));
assertEquals(value, cache.get(key, Object.class));
assertEquals(value, cache.get(key, null));
}
@Test