com.cedarsoft.gdao.caching.CachingService Maven / Gradle / Ivy
package com.cedarsoft.gdao.caching;
import com.cedarsoft.gdao.GenericService;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
*
*/
public class CachingService extends CachingDao implements GenericService {
public CachingService( @NotNull GenericService backingService ) {
super( backingService );
}
@NotNull
protected GenericService getBackingService() {
return ( GenericService ) super.getBackingDao();
}
@Nullable
public R perform( @NotNull final ServiceCallback callback ) {
R returnValue = getBackingService().perform( callback );
cache.getLock().writeLock().lock();
try {
cache.clear();
cache.addAll( getBackingService().findAll() );
} finally {
cache.getLock().writeLock().unlock();
}
return returnValue;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy