View Javadoc

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