1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package net.sf.ashkay;
17
18
19
20
21 /***
22 * CachingStrategies provide abstract strategies about how a cache ought to
23 * perform its caching. When an object is added to the cache, the
24 * CachingStrategy is asked to prepare the CacheEntry for that object. The
25 * CachingStrategy may return a new Entry that serves its purposes better, or
26 * may just set a few properties on the current entry.
27 * <br><br>
28 * When the object is looked up in the cache, the CachingStrategy is asked to
29 * validate this object, if the validation fails for any strategy, the object is
30 * reloaded.
31 *
32 * @author <a href="mailto:bangroot@users.sf.net">Dave Brown</a>
33 */
34 public interface CachingStrategy {
35
36 /***
37 * Prepares the cache entry for caching with this strategy.<br>
38 * <b>NOTE:</b> Be Careful: a caching strategy <em>is</em> allowed to return
39 * a different CacheEntry, so make sure that you store the results of this
40 * method and don't assume the symantics of pass by reference.
41 */
42 public abstract CacheEntry prepare(CacheEntry entry);
43
44 /***
45 * Validates this cache entry for this caching strategy.
46 */
47 public abstract boolean validate(CacheEntry entry);
48 }