
org.dataloader.impl.NoOpValueCache Maven / Gradle / Ivy
package org.dataloader.impl;
import org.dataloader.ValueCache;
import org.dataloader.annotations.Internal;
import java.util.concurrent.CompletableFuture;
/**
* Implementation of {@link ValueCache} that does nothing.
*
* We don't want to store values in memory twice, so when using the default store we just
* say we never have the key and complete the other methods by doing nothing.
*
* @param the type of cache keys
* @param the type of cache values
*
* @author Craig Day
*/
@Internal
public class NoOpValueCache implements ValueCache {
public static NoOpValueCache, ?> NOOP = new NoOpValueCache<>();
/**
* {@inheritDoc}
*/
@Override
public CompletableFuture get(K key) {
return CompletableFutureKit.failedFuture(new UnsupportedOperationException());
}
/**
* {@inheritDoc}
*/
@Override
public CompletableFuture set(K key, V value) {
return CompletableFuture.completedFuture(value);
}
/**
* {@inheritDoc}
*/
@Override
public CompletableFuture delete(K key) {
return CompletableFuture.completedFuture(null);
}
/**
* {@inheritDoc}
*/
@Override
public CompletableFuture clear() {
return CompletableFuture.completedFuture(null);
}
}