01: package com.completex.objective.components.ocache;
02:
03: /**
04: * Cache representing an element of multi-index data structure.
05: * Putting a value into it will populate all the linked caches in following manner:
06: * <PRE>
07: * key1 -> Value (belongs to this OdalLinkedCache)
08: * key2 -> Value (belongs to different OdalLinkedCache)
09: * ....
10: * keyN -> Value (belongs to different OdalLinkedCache)
11: * </PRE>
12: *
13: * Removing the Value by key1 from the cache will remove it from all other linked caches as well
14: *
15: * @author Gennady Krizhevsky
16: */
17: public interface OdalMultiIndexCache extends OdalNotifyingCache,
18: OdalCacheListener, OdalKeyedCache {
19:
20: public static final NullMultiIndexCache NULL_MULTI_INDEX_CACHE = new NullMultiIndexCache(
21: "NULL_MULTI_INDEX_CACHE");
22:
23: /**
24: * Core functionality on get object from cache without notifying the listeners.
25: *
26: * @param key key
27: * @return cached value
28: */
29: Object getNotNotify(Object key);
30:
31: /**
32: * Core functionality on put object to cache without notifying the listeners.
33: *
34: * @param key
35: * @param value value to cache
36: * @return old cache value
37: */
38: Object putNotNotify(Object key, Object value);
39:
40: /**
41: * Return true if this is a Master cache
42: *
43: * @return true if this is a Master cache
44: */
45: boolean isMaster();
46:
47: /**
48: * Returns Master cache for this cache. If this cache is the Master - returns null
49: *
50: * @return Master cache for this cache. If this cache is the Master - returns null
51: */
52: OdalKeyedCache getMasterCache();
53:
54: /**
55: * Sets Master cache for this cache. If this cache is the Master - set null
56: *
57: * @param masterOdalKeyedCache Master cache for this cache. If this cache is the Master - set null
58: */
59: void setMasterCache(OdalMultiIndexCache masterOdalKeyedCache);
60:
61: /**
62: * Null implementation
63: */
64: public static class NullMultiIndexCache extends
65: OdalLinkedCache.NullOdalLinkedCache implements
66: OdalMultiIndexCache {
67:
68: public NullMultiIndexCache(String name) {
69: super (name);
70: }
71:
72: public OdalKeyFactory getMasterOdalKeyFactory() {
73: return OdalKeyFactory.NULL_ODAL_KEY_FACTORY;
74: }
75:
76: public OdalKeyedCache getMasterCache() {
77: return OdalKeyedCache.NULL_ODAL_KEYED_CACHE;
78: }
79:
80: public void setMasterCache(
81: OdalMultiIndexCache masterOdalKeyedCache) {
82: }
83:
84: public boolean isMaster() {
85: return false;
86: }
87:
88: }
89:
90: }
|