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