org.infinispan.quarkus.hibernate.cache.InternalRegionImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of quarkus-local-cache Show documentation
Show all versions of quarkus-local-cache Show documentation
Local-only Hibernate Cache optimized for Quarkus
package org.infinispan.quarkus.hibernate.cache;
import org.hibernate.cache.spi.Region;
import org.jboss.logging.Logger;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Map;
final class InternalRegionImpl implements InternalRegion {
private static final Logger log = Logger.getLogger(InternalRegionImpl.class);
private final Region region;
private volatile long lastRegionInvalidation = Long.MIN_VALUE;
private int invalidations = 0;
private final Map> comparatorsByType = new HashMap<>();
InternalRegionImpl(Region region) {
this.region = region;
}
@Override
public boolean checkValid() {
return lastRegionInvalidation != Long.MAX_VALUE;
}
@Override
public void beginInvalidation() {
if (log.isTraceEnabled()) {
log.trace("Begin invalidating region: " + region.getName());
}
synchronized (this) {
lastRegionInvalidation = Long.MAX_VALUE;
++invalidations;
}
}
@Override
public void endInvalidation() {
synchronized (this) {
if (--invalidations == 0) {
lastRegionInvalidation = region.getRegionFactory().nextTimestamp();
}
}
if (log.isTraceEnabled()) {
log.trace("End invalidating region: " + region.getName());
}
}
@Override
public long getLastRegionInvalidation() {
return lastRegionInvalidation;
}
@Override
public String getName() {
return region.getName();
}
@Override
public void clear() {
region.clear();
}
@Override
public Comparator
© 2015 - 2025 Weber Informatics LLC | Privacy Policy