use of net.sf.ehcache.Element in project JMPjct by MPjct.
the class Eh method read_query_result.
public void read_query_result(Engine context) {
if (Eh.cache == null)
return;
// Cache this key?
if (this.TTL == 0 || context.buffer.size() == 0)
return;
Element element = new Element(this.key, context.buffer);
element.setTimeToLive(this.TTL);
Eh.cache.put(element);
Eh.cache.releaseWriteLockOnKey(this.key);
}
use of net.sf.ehcache.Element in project jforum2 by rafaelsteil.
the class EhCacheEngine method add.
public void add(String fullyQualifiedName, String key, Object value) {
if (!manager.cacheExists(fullyQualifiedName)) {
try {
manager.addCache(fullyQualifiedName);
} catch (CacheException ce) {
log.error(ce, ce);
throw new RuntimeException(ce);
}
}
Cache cache = manager.getCache(fullyQualifiedName);
Element element = new Element(key, (Serializable) value);
cache.put(element);
}
use of net.sf.ehcache.Element in project CloudStack-archive by CloudStack-extras.
the class GenericDaoBase method toVO.
@DB(txn = false)
protected T toVO(ResultSet result, boolean cache) throws SQLException {
T entity;
try {
entity = _entityBeanType.newInstance();
} catch (InstantiationException e1) {
throw new CloudRuntimeException("Unable to instantiate entity", e1);
} catch (IllegalAccessException e1) {
throw new CloudRuntimeException("Illegal Access", e1);
}
toEntityBean(result, entity);
if (cache && _cache != null) {
try {
_cache.put(new Element(_idField.get(entity), entity));
} catch (final Exception e) {
s_logger.debug("Can't put it in the cache", e);
}
}
return entity;
}
use of net.sf.ehcache.Element in project spring-security by spring-projects.
the class EhCacheBasedAclCacheTests method getFromCacheSerializablePopulatesTransient.
@Test
public void getFromCacheSerializablePopulatesTransient() throws Exception {
when(cache.get(acl.getId())).thenReturn(new Element(acl.getId(), acl));
myCache.putInCache(acl);
ReflectionTestUtils.setField(acl, "permissionGrantingStrategy", null);
ReflectionTestUtils.setField(acl, "aclAuthorizationStrategy", null);
MutableAcl fromCache = myCache.getFromCache(acl.getId());
assertThat(ReflectionTestUtils.getField(fromCache, "aclAuthorizationStrategy")).isNotNull();
assertThat(ReflectionTestUtils.getField(fromCache, "permissionGrantingStrategy")).isNotNull();
}
use of net.sf.ehcache.Element in project ORCID-Source by ORCID.
the class ProfileEntityCacheManagerImpl method retrieve.
@Override
@Transactional
public ProfileEntity retrieve(String orcid) throws IllegalArgumentException {
Object key = new OrcidCacheKey(orcid, releaseName);
Date dbDate = profileEntityManager.getLastModifiedDate(orcid);
ProfileEntity profile = toProfileEntity(profileCache.get(key));
if (needsFresh(dbDate, profile))
try {
synchronized (lockers.obtainLock(orcid)) {
profile = toProfileEntity(profileCache.get(key));
if (needsFresh(dbDate, profile)) {
profile = profileEntityManager.findByOrcid(orcid);
if (profile == null)
throw new IllegalArgumentException("Invalid orcid " + orcid);
if (profile.getGivenPermissionBy() != null) {
profile.getGivenPermissionBy().size();
}
if (profile.getGivenPermissionTo() != null) {
profile.getGivenPermissionTo().size();
}
profileCache.put(new Element(key, profile));
}
}
} finally {
lockers.releaseLock(orcid);
}
return profile;
}
Aggregations