use of net.sf.ehcache.Element in project spring-framework by spring-projects.
the class EhCacheCacheTests method testExpiredElements.
@Test
public void testExpiredElements() throws Exception {
Assume.group(TestGroup.LONG_RUNNING);
String key = "brancusi";
String value = "constantin";
Element brancusi = new Element(key, value);
// ttl = 10s
brancusi.setTimeToLive(3);
nativeCache.put(brancusi);
assertEquals(value, cache.get(key).get());
// wait for the entry to expire
Thread.sleep(5 * 1000);
assertNull(cache.get(key));
}
use of net.sf.ehcache.Element in project killbill by killbill.
the class EhCacheBasedCacheController method putIfAbsent.
public void putIfAbsent(final K key, V value) {
final Element element = new Element(key, value);
cache.putIfAbsent(element);
}
use of net.sf.ehcache.Element in project spring-security by spring-projects.
the class EhCacheBasedUserCache method putUserInCache.
public void putUserInCache(UserDetails user) {
Element element = new Element(user.getUsername(), user);
if (logger.isDebugEnabled()) {
logger.debug("Cache put: " + element.getKey());
}
cache.put(element);
}
use of net.sf.ehcache.Element in project spring-security by spring-projects.
the class EhCacheBasedAclCacheTests method evictCacheObjectIdentity.
@Test
public void evictCacheObjectIdentity() throws Exception {
when(cache.get(acl.getId())).thenReturn(new Element(acl.getId(), acl));
myCache.evictFromCache(acl.getId());
verify(cache).remove(acl.getId());
verify(cache).remove(acl.getObjectIdentity());
}
use of net.sf.ehcache.Element in project spring-security by spring-projects.
the class EhCacheBasedAclCacheTests method getFromCacheSerializable.
@Test
public void getFromCacheSerializable() throws Exception {
when(cache.get(acl.getId())).thenReturn(new Element(acl.getId(), acl));
assertThat(myCache.getFromCache(acl.getId())).isEqualTo(acl);
}
Aggregations