| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
package com.atlassian.core.util; |
| 10 |
|
|
| 11 |
|
import com.opensymphony.module.oscache.base.Cache; |
| 12 |
|
import com.opensymphony.module.oscache.web.ServletCacheAdministrator; |
| 13 |
|
import org.apache.log4j.Category; |
| 14 |
|
|
| 15 |
|
import java.util.Date; |
| 16 |
|
import java.util.Iterator; |
| 17 |
|
import java.util.Map; |
| 18 |
|
|
| 19 |
|
|
| 20 |
|
|
| 21 |
|
|
|
|
|
| 0% |
Uncovered Elements: 34 (34) |
Complexity: 8 |
Complexity Density: 0.33 |
|
| 22 |
|
public class CacheUtils |
| 23 |
|
{ |
| 24 |
|
private static final Category log = Category.getInstance(CacheUtils.class); |
| 25 |
|
|
| 26 |
|
|
| 27 |
|
|
| 28 |
|
|
| 29 |
|
|
| 30 |
|
|
| 31 |
|
|
|
|
|
| 0% |
Uncovered Elements: 16 (16) |
Complexity: 4 |
Complexity Density: 0.33 |
|
| 32 |
0
|
public static void flushCache(String key)... |
| 33 |
|
{ |
| 34 |
0
|
try |
| 35 |
|
{ |
| 36 |
0
|
Map applicationCaches = ServletCacheAdministrator.getApplicationCaches(); |
| 37 |
0
|
for (Iterator iterator = applicationCaches.entrySet().iterator(); iterator.hasNext();) |
| 38 |
|
{ |
| 39 |
0
|
Map.Entry entry = (Map.Entry) iterator.next(); |
| 40 |
0
|
Cache cache = (Cache) entry.getValue(); |
| 41 |
0
|
cache.flushPattern(key); |
| 42 |
|
} |
| 43 |
|
|
| 44 |
0
|
Map sessionCaches = ServletCacheAdministrator.getSessionCaches(); |
| 45 |
0
|
for (Iterator iterator = sessionCaches.entrySet().iterator(); iterator.hasNext();) |
| 46 |
|
{ |
| 47 |
0
|
Map.Entry entry = (Map.Entry) iterator.next(); |
| 48 |
0
|
Cache cache = (Cache) entry.getValue(); |
| 49 |
0
|
cache.flushPattern(key); |
| 50 |
|
} |
| 51 |
|
} |
| 52 |
|
catch (Exception e) |
| 53 |
|
{ |
| 54 |
0
|
log.error("Error flushing caches matching key : " + key + " : " + e, e); |
| 55 |
|
} |
| 56 |
|
} |
| 57 |
|
|
| 58 |
|
|
| 59 |
|
|
| 60 |
|
|
|
|
|
| 0% |
Uncovered Elements: 16 (16) |
Complexity: 4 |
Complexity Density: 0.33 |
|
| 61 |
0
|
public static void flushAll()... |
| 62 |
|
{ |
| 63 |
|
|
| 64 |
0
|
try |
| 65 |
|
{ |
| 66 |
0
|
Map applicationCaches = ServletCacheAdministrator.getApplicationCaches(); |
| 67 |
0
|
for (Iterator iterator = applicationCaches.entrySet().iterator(); iterator.hasNext();) |
| 68 |
|
{ |
| 69 |
0
|
Map.Entry entry = (Map.Entry) iterator.next(); |
| 70 |
0
|
Cache cache = (Cache) entry.getValue(); |
| 71 |
0
|
cache.flushAll(new Date()); |
| 72 |
|
} |
| 73 |
|
|
| 74 |
0
|
Map sessionCaches = ServletCacheAdministrator.getSessionCaches(); |
| 75 |
0
|
for (Iterator iterator = sessionCaches.entrySet().iterator(); iterator.hasNext();) |
| 76 |
|
{ |
| 77 |
0
|
Map.Entry entry = (Map.Entry) iterator.next(); |
| 78 |
0
|
Cache cache = (Cache) entry.getValue(); |
| 79 |
0
|
cache.flushAll(new Date()); |
| 80 |
|
} |
| 81 |
|
} |
| 82 |
|
catch (Exception e) |
| 83 |
|
{ |
| 84 |
0
|
log.error("Error flushing all caches: " + e, e); |
| 85 |
|
} |
| 86 |
|
} |
| 87 |
|
} |