use of net.sf.ehcache.Element in project ORCID-Source by ORCID.
the class OrcidGenerationManagerImpl method isInRecentOrcidCache.
private boolean isInRecentOrcidCache(String formattedOrcid) {
LOGGER.debug("Recent ORCID cache size: {}", recentOrcidCache.getSize());
Element alreadyUsed = recentOrcidCache.get(formattedOrcid);
if (alreadyUsed != null) {
LOGGER.debug("Same ORCID randomly generated a few moments ago: {}", formattedOrcid);
return true;
}
return false;
}
use of net.sf.ehcache.Element in project ORCID-Source by ORCID.
the class OrcidGenerationManagerImpl method createNewOrcid.
@Override
public String createNewOrcid() {
String orcid = getNextOrcid();
while (isInRecentOrcidCache(orcid) || profileEntityManager.orcidExists(orcid)) {
orcid = getNextOrcid();
}
recentOrcidCache.put(new Element(orcid, orcid));
return orcid;
}
use of net.sf.ehcache.Element in project OpenClinica by OpenClinica.
the class EhCacheWrapper method get.
public V get(final K key) {
String db_type = CoreResources.getField("dbType");
if (db_type.equalsIgnoreCase("postgres")) {
Element element = null;
Ehcache ehCache = getCache();
if (ehCache != null) {
element = getCache().get(key);
logMe("element null" + element);
}
if (element != null) {
logMe("element not null" + element);
return (V) element.getObjectValue();
}
}
return null;
}
use of net.sf.ehcache.Element in project OpenClinica by OpenClinica.
the class RandomizationRegistrar method getCachedRandomizationDTOObject.
public SeRandomizationDTO getCachedRandomizationDTOObject(String studyOid, Boolean resetCache) throws Exception {
// check if exist in cache ;
SeRandomizationDTO seRandomizationDTO = null;
String ocUrl = CoreResources.getField("sysURL.base");
String mapKey = ocUrl + studyOid;
Element element = cache.get(mapKey);
if (element != null && element.getObjectValue() != null && !resetCache) {
seRandomizationDTO = (SeRandomizationDTO) element.getObjectValue();
}
if (seRandomizationDTO == null) {
seRandomizationDTO = getRandomizationDTOObject(studyOid);
}
if (seRandomizationDTO != null) {
cache.put(new Element(mapKey, seRandomizationDTO));
}
return seRandomizationDTO;
}
use of net.sf.ehcache.Element in project ORCID-Source by ORCID.
the class ClientDetailsEntityCacheManagerImpl method retrieve.
@Override
public ClientDetailsEntity retrieve(String clientId) throws IllegalArgumentException {
Object key = new ClientIdCacheKey(clientId, releaseName);
Date dbDate = retrieveLastModifiedDate(clientId);
ClientDetailsEntity clientDetails = toClientDetailsEntity(clientDetailsCache.get(key));
if (needsFresh(dbDate, clientDetails)) {
try {
synchronized (lockers.obtainLock(clientId)) {
clientDetails = toClientDetailsEntity(clientDetailsCache.get(key));
if (needsFresh(dbDate, clientDetails)) {
clientDetails = clientDetailsManager.findByClientId(clientId);
if (clientDetails == null)
throw new IllegalArgumentException("Invalid client id " + clientId);
clientDetailsCache.put(new Element(key, clientDetails));
}
}
} finally {
lockers.releaseLock(clientId);
}
}
return clientDetails;
}
Aggregations