@@ -685,21 +685,15 @@ public DataLoader<K, V> clearAll(BiConsumer<Void, Throwable> handler) {
685685 /**
686686 * Primes the cache with the given key and value. Note this will only prime the future cache
687687 * and not the value store. Use {@link ValueCache#set(Object, Object)} if you want
688- * o prime it with values before use
688+ * to prime it with values before use
689689 *
690690 * @param key the key
691691 * @param value the value
692692 *
693693 * @return the data loader for fluent coding
694694 */
695695 public DataLoader <K , V > prime (K key , V value ) {
696- Object cacheKey = getCacheKey (key );
697- synchronized (this ) {
698- if (!futureCache .containsKey (cacheKey )) {
699- futureCache .set (cacheKey , CompletableFuture .completedFuture (value ));
700- }
701- }
702- return this ;
696+ return prime (key , CompletableFuture .completedFuture (value ));
703697 }
704698
705699 /**
@@ -711,9 +705,25 @@ public DataLoader<K, V> prime(K key, V value) {
711705 * @return the data loader for fluent coding
712706 */
713707 public DataLoader <K , V > prime (K key , Exception error ) {
708+ return prime (key , CompletableFutureKit .failedFuture (error ));
709+ }
710+
711+ /**
712+ * Primes the cache with the given key and value. Note this will only prime the future cache
713+ * and not the value store. Use {@link ValueCache#set(Object, Object)} if you want
714+ * to prime it with values before use
715+ *
716+ * @param key the key
717+ * @param value the value
718+ *
719+ * @return the data loader for fluent coding
720+ */
721+ public DataLoader <K , V > prime (K key , CompletableFuture <V > value ) {
714722 Object cacheKey = getCacheKey (key );
715- if (!futureCache .containsKey (cacheKey )) {
716- futureCache .set (cacheKey , CompletableFutureKit .failedFuture (error ));
723+ synchronized (this ) {
724+ if (!futureCache .containsKey (cacheKey )) {
725+ futureCache .set (cacheKey , value );
726+ }
717727 }
718728 return this ;
719729 }
0 commit comments