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.ehcache3.configuration; |
35 |
|
|
36 |
|
import info.magnolia.module.cache.filter.CachedEntry; |
37 |
|
|
38 |
|
import java.util.concurrent.TimeUnit; |
39 |
|
|
40 |
|
import org.ehcache.ValueSupplier; |
41 |
|
import org.ehcache.expiry.Duration; |
42 |
|
import org.ehcache.expiry.Expiry; |
43 |
|
|
44 |
|
|
45 |
|
@link@link@link |
46 |
|
@param |
47 |
|
@param |
48 |
|
|
|
|
| 50% |
Uncovered Elements: 13 (26) |
Complexity: 11 |
Complexity Density: 1.1 |
|
49 |
|
public class EhCache3Expiry<K, V> implements Expiry<K, V> { |
50 |
|
|
51 |
|
private Duration create = Duration.INFINITE; |
52 |
|
private Duration access = null; |
53 |
|
private Duration update = null; |
54 |
|
|
|
|
| 88.9% |
Uncovered Elements: 1 (9) |
Complexity: 3 |
Complexity Density: 0.6 |
|
55 |
3 |
@Override... |
56 |
|
public Duration getExpiryForCreation(K key, V value) { |
57 |
3 |
Duration duration = create; |
58 |
3 |
if (value instanceof CachedEntry) { |
59 |
1 |
int ttl = ((CachedEntry) value).getTimeToLiveInSeconds(); |
60 |
1 |
duration = ttl == -1 ? create : new Duration(ttl, TimeUnit.SECONDS); |
61 |
|
} |
62 |
3 |
return duration; |
63 |
|
} |
64 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
65 |
3 |
@Override... |
66 |
|
public Duration getExpiryForAccess(K key, ValueSupplier<? extends V> value) { |
67 |
3 |
return access; |
68 |
|
} |
69 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
70 |
1 |
@Override... |
71 |
|
public Duration getExpiryForUpdate(K key, ValueSupplier<? extends V> oldValue, V newValue) { |
72 |
1 |
return update; |
73 |
|
} |
74 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 2 |
Complexity Density: 2 |
|
75 |
0 |
public Long getCreate() {... |
76 |
0 |
return create == null ? null : create.getLength(); |
77 |
|
} |
78 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
79 |
|
public void setCreate(Long create) {... |
80 |
|
this.create = new Duration(create, TimeUnit.SECONDS); |
81 |
|
} |
82 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 2 |
Complexity Density: 2 |
|
83 |
0 |
public Long getAccess() {... |
84 |
0 |
return access == null ? null : access.getLength(); |
85 |
|
} |
86 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
87 |
|
public void setAccess(Long access) {... |
88 |
|
this.access = new Duration(access, TimeUnit.SECONDS); |
89 |
|
} |
90 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 2 |
Complexity Density: 2 |
|
91 |
0 |
public Long getUpdate() {... |
92 |
0 |
return update == null ? null : update.getLength(); |
93 |
|
} |
94 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
95 |
|
public void setUpdate(Long update) {... |
96 |
|
this.update = new Duration(update, TimeUnit.SECONDS); |
97 |
|
} |
98 |
|
} |