Search in sources :

Example 1 with WorkLastModifiedEntity

use of org.orcid.persistence.jpa.entities.WorkLastModifiedEntity in project ORCID-Source by ORCID.

the class WorkEntityCacheManagerImpl method retrieveWorkLastModifiedList.

@Override
public List<WorkLastModifiedEntity> retrieveWorkLastModifiedList(String orcid, long profileLastModified) {
    Object key = new ProfileCacheKey(orcid, profileLastModified, releaseName);
    List<WorkLastModifiedEntity> workLastModifiedList = toWorkLastModifiedList(getFromWorkLastModifiedCache(key));
    if (workLastModifiedList == null) {
        try {
            synchronized (lockers.obtainLock(orcid)) {
                workLastModifiedList = toWorkLastModifiedList(getFromWorkLastModifiedCache(key));
                if (workLastModifiedList == null) {
                    workLastModifiedList = workDao.getWorkLastModifiedList(orcid);
                    workLastModifiedCache.put(new Element(key, workLastModifiedList));
                }
            }
        } finally {
            lockers.releaseLock(orcid);
        }
    }
    return workLastModifiedList;
}
Also used : WorkLastModifiedEntity(org.orcid.persistence.jpa.entities.WorkLastModifiedEntity) Element(net.sf.ehcache.Element)

Example 2 with WorkLastModifiedEntity

use of org.orcid.persistence.jpa.entities.WorkLastModifiedEntity in project ORCID-Source by ORCID.

the class WorkEntityCacheManagerImpl method retrievePublicWorkLastModifiedList.

@Override
public List<WorkLastModifiedEntity> retrievePublicWorkLastModifiedList(String orcid, long profileLastModified) {
    Object key = new ProfileCacheKey(orcid, profileLastModified, releaseName);
    List<WorkLastModifiedEntity> workLastModifiedList = toWorkLastModifiedList(getFromPublicWorkLastModifiedCache(key));
    if (workLastModifiedList == null) {
        try {
            synchronized (publicWorkLastModifiedListLockers.obtainLock(orcid)) {
                workLastModifiedList = toWorkLastModifiedList(getFromPublicWorkLastModifiedCache(key));
                if (workLastModifiedList == null) {
                    workLastModifiedList = workDao.getPublicWorkLastModifiedList(orcid);
                    publicWorkLastModifiedCache.put(new Element(key, workLastModifiedList));
                }
            }
        } finally {
            publicWorkLastModifiedListLockers.releaseLock(orcid);
        }
    }
    return workLastModifiedList;
}
Also used : WorkLastModifiedEntity(org.orcid.persistence.jpa.entities.WorkLastModifiedEntity) Element(net.sf.ehcache.Element)

Aggregations

Element (net.sf.ehcache.Element)2 WorkLastModifiedEntity (org.orcid.persistence.jpa.entities.WorkLastModifiedEntity)2