1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34 package info.magnolia.module.cache;
35
36 import info.magnolia.module.cache.cachepolicy.result.CachePolicyResultProvider;
37 import info.magnolia.objectfactory.Components;
38
39
40
41
42
43
44 public class CachePolicyResult {
45 public static final CachePolicyBehaviour store = new CachePolicyBehaviour("store");
46 public static final CachePolicyBehaviour useCache = new CachePolicyBehaviour("useCache");
47 public static final CachePolicyBehaviour bypass = new CachePolicyBehaviour("bypass");
48
49 private Object cachedEntry;
50 private String cacheName;
51 private final CachePolicyBehaviour behaviour;
52 private final Object cacheKey;
53
54 public CachePolicyResult(CachePolicyBehaviour behaviour, Object cacheKey, Object cachedEntry) {
55 this.behaviour = behaviour;
56 this.cacheKey = cacheKey;
57 this.cachedEntry = cachedEntry;
58 }
59
60 public CachePolicyBehaviour getBehaviour() {
61 return behaviour;
62 }
63
64 public Object getCacheKey() {
65 return cacheKey;
66 }
67
68 public void setCachedEntry(Object entry) {
69 cachedEntry = entry;
70 }
71
72 public Object getCachedEntry() {
73 return cachedEntry;
74 }
75
76 public void setCacheName(String cacheName) {
77 this.cacheName = cacheName;
78 }
79
80 public String getCacheName() {
81 return cacheName;
82 }
83
84 @Override
85 public String toString() {
86 return "CachePolicyResult{" +
87 "behaviour=" + behaviour +
88 ", cacheKey=" + cacheKey +
89 ", cachedEntry=" + cachedEntry +
90 '}';
91 }
92
93
94
95
96 public final static class CachePolicyBehaviour {
97 private final String name;
98
99 private CachePolicyBehaviour(String name) {
100 this.name = name;
101 }
102
103 @Override
104 public String toString() {
105 return name;
106 }
107
108 public String getName() {
109 return name;
110 }
111 }
112
113
114
115
116
117
118 @Deprecated
119 public static void setCurrent(CachePolicyResult cachePolicyResult) {
120 Components.getComponent(CachePolicyResultProvider.class).setCachePolicyResult(cachePolicyResult);
121 }
122
123
124
125
126
127
128 @Deprecated
129 public static CachePolicyResult getCurrent() {
130 return Components.getComponent(CachePolicyResultProvider.class).getCachePolicyResult();
131 }
132
133 }