1 package com.atlassian.vcache;
2
3 import java.time.Duration;
4 import java.util.Collection;
5 import javax.annotation.Nonnull;
6
7 import com.atlassian.annotations.PublicApi;
8
9 /**
10 * Interface that defines the JVM cache operations.
11 *
12 * <p>Notes:</p>
13 * <ul>
14 * <li>{@code null} keys and values are <b>NOT</b> supported</li>
15 * <li>keys and values are stored by reference</li>
16 * </ul>
17 *
18 * <h1>Notes</h1>
19 * <ul>
20 * <li>
21 * A cache has an associated time-to-live (<tt>ttl</tt>), which is expressed as {@link Duration}.
22 * The implementations may round-up the supplied ttl to the nearest second. E.g. 500 milliseconds may be
23 * converted to 1 second.
24 * </li>
25 * <li>
26 * Do not assume that the associated ttl defines exactly when entries are evicted. The implementation is free
27 * to choose how the ttl is interpreted. It may expire entries in a timely manner, or it may be delayed until
28 * next interaction with the cache.
29 * </li>
30 * </ul>
31 *
32 * @param <K> the key type
33 * @param <V> the value type
34 *
35 * @since 1.0
36 */
37 @PublicApi
38 public interface JvmCache<K, V> extends VCache, LocalCacheOperations<K, V>
39 {
40 /**
41 * Gets the keys of all objects currently stored in the cache. This will return the keys in a new mutable collection.
42 * @return a collection of {@link Object}s keys
43 */
44 @Nonnull
45 Collection<K> getKeys(); // TODO: remove this - any objections?
46 }