Code example for Cache

Methods: getIfPresentput

0
	   
 
  //TODO ideally other calls with to an equal uncached label should block and wait for a single retrieval 
  @Override 
  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()) { 
        log.info("Caching {} candidates for label {}", candidates.size(), label);
      } 
    } 
 
    return candidates;
  } 
 
  @Override 
Experience pair programming with AI  Get Codota for Java