1 package com.atlassian.vcache;
2
3 import java.util.Arrays;
4 import java.util.concurrent.CompletableFuture;
5 import javax.annotation.Nonnull;
6
7 import com.atlassian.annotations.PublicApi;
8
9 /**
10 * Represents the unbuffered write operations on an {@link ExternalCache}.
11 *
12 * @param <V> the value type
13 *
14 * @since 1.0
15 */
16 @PublicApi
17 public interface ExternalWriteOperationsUnbuffered<V>
18 {
19 /**
20 * Puts the value under the specified key using the specified policy.
21 *
22 * @param key the key to put the data under
23 * @param value the value to associate with the key.
24 * @param policy the policy to apply
25 * @return whether the entry was put into the cache.
26 */
27 @Nonnull
28 CompletableFuture<Boolean> put(String key, V value, PutPolicy policy);
29
30 /**
31 * Remove the entries with the specified keys.
32 *
33 * @param keys the keys of the entries to remove.
34 * @return no indication is given as to whether the entries existed before they were deleted
35 */
36 @SuppressWarnings("unchecked")
37 @Nonnull
38 default CompletableFuture<Void> remove(String... keys)
39 {
40 return remove(Arrays.asList(keys));
41 }
42
43 /**
44 * Remove the entries with the specified keys.
45 *
46 * @param keys the keys of the entries to remove.
47 * @return no indication is given as to whether the entries existed before they were deleted
48 */
49 @Nonnull
50 CompletableFuture<Void> remove(Iterable<String> keys);
51
52 /**
53 * Remove all entries in the cache.
54 *
55 * @return no indication is given as to whether entries existed before they were deleted
56 */
57 @Nonnull
58 CompletableFuture<Void> removeAll();
59 }