Code example for Cache

Methods: put

0
public class InProcessCredentialStore extends AbstractIdleService implements CredentialStore {
  private final Cache<CredentialKey, Map<String, Object>> cache = CacheBuilder.newBuilder().build();
 
  @Override 
  public void set(String tenantId, String clusterId, Map<String, Object> fields) {
    cache.put(new CredentialKey(tenantId, clusterId), fields);
  } 
 
  @Override 
  public Map<String, Object> get(String tenantId, String clusterId) {
    Map<String, Object> result = cache.getIfPresent(new CredentialKey(tenantId, clusterId));
    return result == null ? Collections.<String, Object>emptyMap() : result;
  } 
 
  @Override 
  public void wipe(String tenantId, String clusterId) {
    cache.invalidate(new CredentialKey(tenantId, clusterId));
  } 
 
  @Override 
Experience pair programming with AI  Get Codota for Java