// Path: src/main/java/org/dataloader/impl/DefaultCacheMap.java
// @Internal
// public class DefaultCacheMap<K, V> implements CacheMap<K, V> {
// 
//     private final Map<K, CompletableFuture<V>> cache;
// 
//     /**
//      * Default constructor
//      */
//     public DefaultCacheMap() {
//         cache = new HashMap<>();
//     }
// 
//     /**
//      * {@inheritDoc}
//      */
//     @Override
//     public boolean containsKey(K key) {
//         return cache.containsKey(key);
//     }
// 
// 
//     /**
//      * {@inheritDoc}
//      */
//     @Override
//     public CompletableFuture<V> get(K key) {
//         return cache.get(key);
//     }
// 
//     /**
//      * {@inheritDoc}
//      */
//     @Override
//     public CacheMap<K, V> set(K key, CompletableFuture<V> value) {
//         cache.put(key, value);
//         return this;
//     }
// 
//     /**
//      * {@inheritDoc}
//      */
//     @Override
//     public CacheMap<K, V> delete(K key) {
//         cache.remove(key);
//         return this;
//     }
// 
//     /**
//      * {@inheritDoc}
//      */
//     @Override
//     public CacheMap<K, V> clear() {
//         cache.clear();
//         return this;
//     }
// }


import org.dataloader.annotations.PublicSpi;
import org.dataloader.impl.DefaultCacheMap;
import java.util.concurrent.CompletableFuture;
/*
 * Copyright (c) 2016 The original author or authors
 *
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * and Apache License v2.0 which accompanies this distribution.
 *
 *      The Eclipse Public License is available at
 *      http://www.eclipse.org/legal/epl-v10.html
 *
 *      The Apache License v2.0 is available at
 *      http://www.opensource.org/licenses/apache2.0.php
 *
 * You may elect to redistribute this code under either of these licenses.
 */

package org.dataloader;



/**
 * CacheMap is used by data loaders that use caching promises to values aka {@link CompletableFuture}&lt;V&gt;.  A better name for this
 * class might have been FutureCache but that is history now.
 * <p>
 * The default implementation used by the data loader is based on a {@link java.util.LinkedHashMap}.
 * <p>
 * This is really a cache of completed {@link CompletableFuture}&lt;V&gt; values in memory.  It is used, when caching is enabled, to
 * give back the same future to any code that may call it.  If you need a cache of the underlying values that is possible external to the JVM
 * then you will want to use {{@link ValueCache}} which is designed for external cache access.
 *
 * @param <K> type parameter indicating the type of the cache keys
 * @param <V> type parameter indicating the type of the data that is cached
 *
 * @author <a href="https://github.com/aschrijver/">Arnold Schrijver</a>
 * @author <a href="https://github.com/bbakerman/">Brad Baker</a>
 */
@PublicSpi
public interface CacheMap<K, V> {

    /**
     * Creates a new cache map, using the default implementation that is based on a {@link java.util.LinkedHashMap}.
     *
     * @param <K> type parameter indicating the type of the cache keys
     * @param <V> type parameter indicating the type of the data that is cached
     *
     * @return the cache map
     */
    static <K, V> CacheMap<K, V> simpleMap() {
// Path: src/main/java/org/dataloader/impl/DefaultCacheMap.java
// @Internal
// public class DefaultCacheMap<K, V> implements CacheMap<K, V> {
// 
//     private final Map<K, CompletableFuture<V>> cache;
// 
//     /**
//      * Default constructor
//      */
//     public DefaultCacheMap() {
//         cache = new HashMap<>();
//     }
// 
//     /**
//      * {@inheritDoc}
//      */
//     @Override
//     public boolean containsKey(K key) {
//         return cache.containsKey(key);
//     }
// 
// 
//     /**
//      * {@inheritDoc}
//      */
//     @Override
//     public CompletableFuture<V> get(K key) {
//         return cache.get(key);
//     }
// 
//     /**
//      * {@inheritDoc}
//      */
//     @Override
//     public CacheMap<K, V> set(K key, CompletableFuture<V> value) {
//         cache.put(key, value);
//         return this;
//     }
// 
//     /**
//      * {@inheritDoc}
//      */
//     @Override
//     public CacheMap<K, V> delete(K key) {
//         cache.remove(key);
//         return this;
//     }
// 
//     /**
//      * {@inheritDoc}
//      */
//     @Override
//     public CacheMap<K, V> clear() {
//         cache.clear();
//         return this;
//     }
// }


// Path: src/main/java/org/dataloader/CacheMap.java
import org.dataloader.annotations.PublicSpi;
import org.dataloader.impl.DefaultCacheMap;
import java.util.concurrent.CompletableFuture;

/*
 * Copyright (c) 2016 The original author or authors
 *
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * and Apache License v2.0 which accompanies this distribution.
 *
 *      The Eclipse Public License is available at
 *      http://www.eclipse.org/legal/epl-v10.html
 *
 *      The Apache License v2.0 is available at
 *      http://www.opensource.org/licenses/apache2.0.php
 *
 * You may elect to redistribute this code under either of these licenses.
 */

package org.dataloader;



/**
 * CacheMap is used by data loaders that use caching promises to values aka {@link CompletableFuture}&lt;V&gt;.  A better name for this
 * class might have been FutureCache but that is history now.
 * <p>
 * The default implementation used by the data loader is based on a {@link java.util.LinkedHashMap}.
 * <p>
 * This is really a cache of completed {@link CompletableFuture}&lt;V&gt; values in memory.  It is used, when caching is enabled, to
 * give back the same future to any code that may call it.  If you need a cache of the underlying values that is possible external to the JVM
 * then you will want to use {{@link ValueCache}} which is designed for external cache access.
 *
 * @param <K> type parameter indicating the type of the cache keys
 * @param <V> type parameter indicating the type of the data that is cached
 *
 * @author <a href="https://github.com/aschrijver/">Arnold Schrijver</a>
 * @author <a href="https://github.com/bbakerman/">Brad Baker</a>
 */
@PublicSpi
public interface CacheMap<K, V> {

    /**
     * Creates a new cache map, using the default implementation that is based on a {@link java.util.LinkedHashMap}.
     *
     * @param <K> type parameter indicating the type of the cache keys
     * @param <V> type parameter indicating the type of the data that is cached
     *
     * @return the cache map
     */
    static <K, V> CacheMap<K, V> simpleMap() {
        return new DefaultCacheMap<>();