| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
package org.kuali.student.common.util; |
| 17 |
|
|
| 18 |
|
import java.io.Serializable; |
| 19 |
|
|
| 20 |
|
import net.sf.ehcache.Cache; |
| 21 |
|
import net.sf.ehcache.CacheManager; |
| 22 |
|
import net.sf.ehcache.Element; |
| 23 |
|
|
| 24 |
|
|
| 25 |
|
|
| 26 |
|
@author |
| 27 |
|
|
| 28 |
|
|
|
|
|
| 0% |
Uncovered Elements: 47 (47) |
Complexity: 17 |
Complexity Density: 0.68 |
|
| 29 |
|
public class EhCacheHelper { |
| 30 |
|
|
| 31 |
|
private CacheManager cacheManager; |
| 32 |
|
|
| 33 |
|
|
| 34 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 35 |
0
|
public EhCacheHelper() {... |
| 36 |
0
|
initCacheManager(); |
| 37 |
|
} |
| 38 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 39 |
0
|
public EhCacheHelper(String configurationFileName) {... |
| 40 |
0
|
initCacheManager(configurationFileName); |
| 41 |
|
} |
| 42 |
|
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
| 43 |
0
|
private void initCacheManager(String configurationFileName) {... |
| 44 |
0
|
if(cacheManager == null) { |
| 45 |
0
|
cacheManager = CacheManager.create(configurationFileName); |
| 46 |
|
} |
| 47 |
|
} |
| 48 |
|
|
| 49 |
|
|
| 50 |
|
|
| 51 |
|
|
| 52 |
|
@see |
| 53 |
|
@see |
| 54 |
|
|
| 55 |
|
|
| 56 |
|
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
| 57 |
0
|
private void initCacheManager() {... |
| 58 |
|
|
| 59 |
0
|
if(cacheManager == null) { |
| 60 |
0
|
cacheManager = CacheManager.create(); |
| 61 |
|
} |
| 62 |
|
} |
| 63 |
|
|
| 64 |
|
|
| 65 |
|
|
| 66 |
|
@param |
| 67 |
|
|
| 68 |
|
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
| 69 |
0
|
public void createCache(String cacheName) {... |
| 70 |
0
|
if(!cacheManager.cacheExists(cacheName)) { |
| 71 |
0
|
cacheManager.addCache(cacheName); |
| 72 |
|
} |
| 73 |
|
} |
| 74 |
|
|
| 75 |
|
|
| 76 |
|
|
| 77 |
|
|
| 78 |
|
@param |
| 79 |
|
@param |
| 80 |
|
@param |
| 81 |
|
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
| 82 |
0
|
public void saveOrUpdateCacheElement(String cacheName, String key, Object value) {... |
| 83 |
0
|
Cache cache = cacheManager.getCache(cacheName); |
| 84 |
0
|
Element element = new Element(key, value); |
| 85 |
0
|
cache.put(element); |
| 86 |
|
} |
| 87 |
|
|
| 88 |
|
|
| 89 |
|
|
| 90 |
|
@param |
| 91 |
|
@param |
| 92 |
|
@return |
| 93 |
|
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
| 94 |
0
|
public Serializable getCacheElementValue(String cacheName, String key) {... |
| 95 |
0
|
Element element = getCacheElement(cacheName, key); |
| 96 |
0
|
if(element == null) { |
| 97 |
0
|
return null; |
| 98 |
|
} |
| 99 |
0
|
return element.getValue(); |
| 100 |
|
} |
| 101 |
|
|
| 102 |
|
|
| 103 |
|
|
| 104 |
|
|
| 105 |
|
@param |
| 106 |
|
@param |
| 107 |
|
@return |
| 108 |
|
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 109 |
0
|
public Element getCacheElement(String cacheName, String key) {... |
| 110 |
0
|
Cache cache = cacheManager.getCache(cacheName); |
| 111 |
0
|
return cache.get(key); |
| 112 |
|
} |
| 113 |
|
|
| 114 |
|
|
| 115 |
|
|
| 116 |
|
@param |
| 117 |
|
@param |
| 118 |
|
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 119 |
0
|
public void evictCacheElement(String cacheName, String key) {... |
| 120 |
0
|
Cache cache = cacheManager.getCache(cacheName); |
| 121 |
0
|
cache.remove(key); |
| 122 |
|
} |
| 123 |
|
|
| 124 |
|
|
| 125 |
|
|
| 126 |
|
@param |
| 127 |
|
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 128 |
0
|
public void evictAllCacheElements(String cacheName) {... |
| 129 |
0
|
Cache cache = cacheManager.getCache(cacheName); |
| 130 |
0
|
cache.removeAll(); |
| 131 |
|
} |
| 132 |
|
|
| 133 |
|
|
| 134 |
|
|
| 135 |
|
@param |
| 136 |
|
@return |
| 137 |
|
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 138 |
0
|
public long getCacheElementHitCount(Element element) {... |
| 139 |
0
|
if(element == null) { |
| 140 |
0
|
return 0; |
| 141 |
|
} |
| 142 |
0
|
return element.getHitCount(); |
| 143 |
|
} |
| 144 |
|
|
| 145 |
|
|
| 146 |
|
@return |
| 147 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 148 |
0
|
public String[] getCacheNames() {... |
| 149 |
0
|
return cacheManager.getCacheNames(); |
| 150 |
|
} |
| 151 |
|
} |