Code example for Cache

Methods: getIfPresentput

  //TODO ideally other calls with to an equal uncached label should block and wait for a single retrieval 
  public FastIDSet getCandidates(String label) throws IOException {
    FastIDSet candidates = cache.getIfPresent(label);
    if (candidates == null) {
      candidates = delegate.getCandidates(label);
      cache.put(label, candidates);
      if (log.isInfoEnabled()) {"Caching {} candidates for label {}", candidates.size(), label);
    return candidates;
Experience pair programming with AI  Get Codota for Java