cloud.eppo.api.AbstractAssignmentCache Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sdk-common-jvm Show documentation
Show all versions of sdk-common-jvm Show documentation
Eppo SDK for JVM shared library
package cloud.eppo.api;
import cloud.eppo.cache.AssignmentCacheEntry;
import cloud.eppo.cache.AssignmentCacheKey;
import java.util.Map;
/**
* {@link IAssignmentCache} implementation which takes a map to use as the underlying storage
* mechanism.
*/
public abstract class AbstractAssignmentCache implements IAssignmentCache {
protected final Map delegate;
protected AbstractAssignmentCache(final Map delegate) {
this.delegate = delegate;
}
@Override
public boolean hasEntry(AssignmentCacheEntry entry) {
String serializedEntry = get(entry.getKey());
return serializedEntry != null && serializedEntry.equals(entry.getValueKeyString());
}
private String get(AssignmentCacheKey key) {
return delegate.get(key.toString());
}
@Override
public void put(AssignmentCacheEntry entry) {
delegate.put(entry.getKeyString(), entry.getValueKeyString());
}
}