use of net.sf.ehcache.Element in project ORCID-Source by ORCID.
the class OrcidProfileCacheManagerImpl method retrievePublic.
@Override
public OrcidProfile retrievePublic(String orcid) {
Object key = new OrcidCacheKey(orcid, releaseName);
Date dbDate = retrieveLastModifiedDate(orcid);
OrcidProfile op = toOrcidProfile(publicProfileCache.get(key));
if (needsFresh(dbDate, op))
try {
synchronized (pubLocks.obtainLock(orcid)) {
op = toOrcidProfile(publicProfileCache.get(orcid));
if (needsFresh(dbDate, op)) {
op = orcidProfileManager.retrievePublicOrcidProfile(orcid);
publicProfileCache.put(new Element(key, op));
}
}
} finally {
pubLocks.releaseLock(orcid);
}
return op;
}
use of net.sf.ehcache.Element in project ORCID-Source by ORCID.
the class OrcidProfileCacheManagerImpl method retrieve.
@Override
public OrcidProfile retrieve(String orcid) {
Object key = new OrcidCacheKey(orcid, releaseName);
Date dbDate = retrieveLastModifiedDate(orcid);
OrcidProfile op = toOrcidProfile(profileCache.get(key));
if (needsFresh(dbDate, op))
try {
synchronized (profileLockers.obtainLock(orcid)) {
op = toOrcidProfile(profileCache.get(orcid));
if (needsFresh(dbDate, op)) {
op = orcidProfileManager.retrieveFreshOrcidProfile(orcid, LoadOptions.ALL);
profileCache.put(new Element(key, op));
}
}
} finally {
profileLockers.releaseLock(orcid);
}
return op;
}
use of net.sf.ehcache.Element in project CloudStack-archive by CloudStack-extras.
the class GenericDaoBase method toEntityBean.
@SuppressWarnings("unchecked")
@DB(txn = false)
protected T toEntityBean(final ResultSet result, final boolean cache) throws SQLException {
final T entity = (T) _factory.newInstance(new Callback[] { NoOp.INSTANCE, new UpdateBuilder(this) });
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 cloudstack by apache.
the class GenericDaoBase method toEntityBean.
@SuppressWarnings("unchecked")
@DB()
protected T toEntityBean(final ResultSet result, final boolean cache) throws SQLException {
final T entity = (T) _factory.newInstance(new Callback[] { NoOp.INSTANCE, new UpdateBuilder(this) });
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 cloudstack by apache.
the class IAMServiceImpl method addToIAMCache.
@Override
public void addToIAMCache(Object accessKey, Object allowDeny) {
if (_iamCache != null) {
try {
s_logger.debug("Put IAM access check for " + accessKey + " in cache");
_iamCache.put(new Element(accessKey, allowDeny));
} catch (final Exception e) {
s_logger.debug("Can't put " + accessKey + " to IAM cache", e);
}
}
}
Aggregations