Пример #1
0
  @Override
  public FeatureState getFeatureState(Feature feature) {

    // first try to find it from the cache
    CacheEntry entry = cache.get(feature);
    if (entry != null && !isExpired(entry)) {
      return entry.getState() != null ? entry.getState().copy() : null;
    }

    // no cache hit
    FeatureState featureState = delegate.getFeatureState(feature);

    // cache the result (may be null)
    cache.put(feature, new CacheEntry(featureState != null ? featureState.copy() : null));

    // return the result
    return featureState;
  }
Пример #2
0
 @Override
 public void setFeatureState(FeatureState featureState) {
   delegate.setFeatureState(featureState);
   cache.remove(featureState.getFeature());
 }