View Javadoc

1   package com.atlassian.cache;
2   
3   import javax.annotation.Nonnull;
4   
5   import com.atlassian.annotations.PublicApi;
6   import com.atlassian.util.concurrent.Nullable;
7   
8   /**
9    * A Resettable reference.
10   *
11   * @since 2.0
12   */
13  @PublicApi
14  public interface CachedReference<V>
15  {
16      /**
17       * Get a value from the cache.
18       *
19       * @return the cached value
20       */
21      @Nonnull
22      V get();
23  
24      /**
25       * Resets (clears/invalidates) this reference.
26       */
27      void reset();
28  
29      /**
30       * Adds a {@link CachedReferenceListener}
31       * @param listener the listener
32       * @param includeValues if the events sent to this listener will include old/new value. This can be used in cases
33       * when the cost of finding these values is big (network sync) but the listener is not interested in the concrete
34       * values for events its getting. The support for this parameter is optional and implementation dependent
35       * @since 2.4
36       */
37      void addListener(@Nonnull CachedReferenceListener<V> listener, boolean includeValues);
38  
39      /**
40       * Removes a {@link CachedReferenceListener}
41       * @param listener the listener
42       * @since 2.4
43       */
44      void removeListener(@Nonnull CachedReferenceListener<V> listener);
45  }