1 package com.atlassian.vcache.internal;
2
3 import java.util.Set;
4
5 /**
6 * The lifecycle management interface that contains methods that need to be called, by the
7 * host application, at different stages.
8 * <p>
9 * Handlers need to be provided that are called whenever a cache is about to be configured by the VCache
10 * implementation. Using these hooks, the host application can:
11 * </p>
12 * <ul>
13 * <li>Override the current cache settings. For example, enforcing an application wide maximum timeout.</li>
14 * <li>
15 * Log a warning (or whatever) based on it's policy (e.g. an unknown {@link com.atlassian.vcache.JvmCache}
16 * is being created.
17 * </li>
18 * <li>
19 * Prevent a cache from being created, based on it's policy, by throwing a {@link RuntimeException}. The
20 * VCache implementation will propagate these exceptions to the original caller.
21 * </li>
22 * </ul>
23 *
24 * @since 1.0
25 */
26 public interface VCacheLifecycleManager {
27 /**
28 * Synchronise the {@link com.atlassian.vcache.TransactionalExternalCache}'s that are associated with the
29 * supplied context.
30 *
31 * @param context the request context to synchronise.
32 */
33 void transactionSync(RequestContext context);
34
35 /**
36 * Discard the {@link com.atlassian.vcache.TransactionalExternalCache}'s that are associated with the
37 * supplied context.
38 *
39 * @param context the request context to discard.
40 * @return names of the caches that have operations being discarded.
41 */
42 Set<String> transactionDiscard(RequestContext context);
43
44 /**
45 * Return the cache metrics for the supplied context.
46 *
47 * @param context the request context to obtain metrics for.
48 * @return the cache metrics for the request
49 */
50 RequestMetrics metrics(RequestContext context);
51 }