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

com.clarifai.api.auth.InMemoryCredentialCache Maven / Gradle / Ivy

The newest version!
package com.clarifai.api.auth;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/** Default in-memory {@link CredentialCache} implementation. */
public class InMemoryCredentialCache implements CredentialCache {
  private static final InMemoryCredentialCache INSTANCE = new InMemoryCredentialCache();

  /** Returns the singleton instance. */
  public static InMemoryCredentialCache getInstance() {
    return INSTANCE;
  }

  private final Map cache = new ConcurrentHashMap();

  public void putCredential(String appId, Credential credential) {
    cache.put(appId, credential);
  }

  public Credential getCredential(String appId) {
    return cache.get(appId);
  }

  public void removeCredential(String appId) {
    cache.remove(appId);
  }

  private InMemoryCredentialCache() {}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy