use of net.sf.ehcache.Element in project metrics by dropwizard.
the class InstrumentedEhcacheTest method measuresGetsAndPuts.
@Test
public void measuresGetsAndPuts() throws Exception {
cache.get("woo");
cache.put(new Element("woo", "whee"));
final Timer gets = registry.timer(name(Cache.class, "test", "gets"));
assertThat(gets.getCount()).isEqualTo(1);
final Timer puts = registry.timer(name(Cache.class, "test", "puts"));
assertThat(puts.getCount()).isEqualTo(1);
}
use of net.sf.ehcache.Element in project gocd by gocd.
the class GoCache method getWithoutTransactionCheck.
private Object getWithoutTransactionCheck(String key) {
Element element = ehCache.get(key);
if (element == null) {
return null;
}
Object value = element.getObjectValue();
logUnsavedPersistentObjectInteraction(value, "PersistentObject %s without an id served out of cache.");
return value;
}
use of net.sf.ehcache.Element in project hibernate-orm by hibernate.
the class EhcacheGeneralDataRegion method put.
@Override
public void put(SharedSessionContractImplementor session, Object key, Object value) throws CacheException {
LOG.debugf("key: %s value: %s", key, value);
try {
final Element element = new Element(key, value);
getCache().put(element);
} catch (IllegalArgumentException e) {
throw new CacheException(e);
} catch (IllegalStateException e) {
throw new CacheException(e);
} catch (net.sf.ehcache.CacheException e) {
if (e instanceof NonStopCacheException) {
HibernateNonstopCacheExceptionHandler.getInstance().handleNonstopCacheException((NonStopCacheException) e);
} else {
throw new CacheException(e);
}
}
}
use of net.sf.ehcache.Element in project hibernate-orm by hibernate.
the class EhcacheTransactionalDataRegion method put.
/**
* Map the given value to the given key, replacing any existing mapping for this key
*
* @param key The cache key
* @param value The data to cache
*
* @throws CacheException Indicates a problem accessing the cache
*/
public final void put(Object key, Object value) throws CacheException {
try {
final Element element = new Element(key, value);
getCache().put(element);
} catch (IllegalArgumentException e) {
throw new CacheException(e);
} catch (IllegalStateException e) {
throw new CacheException(e);
} catch (net.sf.ehcache.CacheException e) {
if (e instanceof NonStopCacheException) {
HibernateNonstopCacheExceptionHandler.getInstance().handleNonstopCacheException((NonStopCacheException) e);
} else {
throw new CacheException(e);
}
}
}
use of net.sf.ehcache.Element in project ninja by ninjaframework.
the class CacheEhCacheImpl method replace.
public void replace(String key, Object value, int expiration) {
if (ehCache.get(key) == null) {
return;
}
Element element = new Element(key, value);
element.setTimeToLive(expiration);
ehCache.put(element);
}
Aggregations