All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.sirix.cache.NamesCache Maven / Gradle / Ivy

Go to download

SirixDB is a hybrid on-disk and in-memory document oriented, versioned database system. It has a lightweight buffer manager, stores everything in a huge persistent and durable tree and allows efficient reconstruction of every revision. Furthermore, SirixDB implements change tracking, diffing and supports time travel queries.

There is a newer version: 0.11.0
Show newest version
package io.sirix.cache;

import com.github.benmanes.caffeine.cache.Caffeine;
import io.sirix.index.name.Names;

import java.util.Map;
import java.util.concurrent.TimeUnit;

public final class NamesCache implements Cache {

  private final com.github.benmanes.caffeine.cache.Cache cache;

  public NamesCache(final int maxSize) {
    cache = Caffeine.newBuilder()
                    .maximumSize(maxSize)
                    .expireAfterAccess(5, TimeUnit.MINUTES)
                    .scheduler(scheduler)
                    .build();
  }

  @Override
  public void clear() {
    cache.invalidateAll();
  }

  @Override
  public Names get(NamesCacheKey key) {
    return cache.getIfPresent(key);
  }

  @Override
  public void put(NamesCacheKey key, Names value) {
    cache.put(key, value);
  }

  @Override
  public void putAll(Map map) {
    cache.putAll(map);
  }

  @Override
  public void toSecondCache() {
    throw new UnsupportedOperationException();
  }

  @Override
  public Map getAll(Iterable keys) {
    return cache.getAllPresent(keys);
  }

  @Override
  public void remove(NamesCacheKey key) {
    cache.invalidate(key);
  }

  @Override
  public void close() {
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy