use of net.sf.ehcache.CacheManager in project ocvn by devgateway.
the class MarkupCacheService method getReportFromCache.
/**
* Fetch the content of a report from cache
*
* @param outputType
* @param reportName
* @param parameters
* @return
*/
public byte[] getReportFromCache(final String outputType, final String reportName, final String parameters) {
CacheManager cm = CacheManager.getInstance();
// get the reports cache "reportsCache", declared in ehcache.xml
Cache cache = cm.getCache("reportsCache");
String key = createCacheKey(outputType, reportName, parameters);
if (cache.isKeyInCache(key)) {
return (byte[]) cache.get(key).getObjectValue();
}
return null;
}
use of net.sf.ehcache.CacheManager in project ocvn by devgateway.
the class MarkupCacheService method addReportToCache.
/**
* Add the content of a report (PDF, Excel, RTF) to cache
*
* @param outputType
* @param reportName
* @param parameters
* @param buffer
*/
public void addReportToCache(final String outputType, final String reportName, final String parameters, final byte[] buffer) {
CacheManager cm = CacheManager.getInstance();
// get the reports cache "reportsCache", declared in ehcache.xml
Cache cache = cm.getCache("reportsCache");
cache.put(new Element(createCacheKey(outputType, reportName, parameters), buffer));
}
use of net.sf.ehcache.CacheManager in project ocvn by devgateway.
the class MarkupCacheService method clearReportsCache.
/**
* Remove from cache all reports content
*/
public void clearReportsCache() {
CacheManager cm = CacheManager.getInstance();
// get the reports cache "reportsCache", declared in ehcache.xml
Cache cache = cm.getCache("reportsCache");
if (cache != null) {
cache.removeAll();
}
}
use of net.sf.ehcache.CacheManager in project uPortal by Jasig.
the class GroupsCacheAuthenticationListenerTest method testUserAuthenticated.
@Test
public void testUserAuthenticated() {
final IPerson person = PersonFactory.createPerson();
person.setAttribute(IPerson.USERNAME, "mock.person");
final IEntityGroup group = new MockEntityGroup("mock.group", IPerson.class);
final CacheManager cacheManager = CacheManager.getInstance();
final Cache parentGroupsCache = new Cache("parentGroupsCache", 100, false, false, 0, 0);
cacheManager.addCache(parentGroupsCache);
parentGroupsCache.put(new Element(person.getEntityIdentifier(), Collections.singleton(group)));
final Cache childrenCache = new Cache("childrenCache", 100, false, false, 0, 0);
cacheManager.addCache(childrenCache);
childrenCache.put(new Element(group.getUnderlyingEntityIdentifier(), new Object()));
Assert.assertEquals(parentGroupsCache.getSize(), 1);
Assert.assertEquals(childrenCache.getSize(), 1);
final LocalGroupsCacheAuthenticationListener listener = new LocalGroupsCacheAuthenticationListener();
listener.setParentGroupsCache(parentGroupsCache);
listener.setChildrenCache(childrenCache);
listener.userAuthenticated(person);
Assert.assertEquals(parentGroupsCache.getSize(), 0);
Assert.assertEquals(childrenCache.getSize(), 0);
}
use of net.sf.ehcache.CacheManager in project oc-explorer by devgateway.
the class MarkupCacheService method clearReportsApiCache.
/**
* Remove from cache all reports api content
*/
public void clearReportsApiCache() {
CacheManager cm = CacheManager.getInstance();
// get the reports cache "reportsApiCache", declared in ehcache.xml
Cache cache = cm.getCache("reportsApiCache");
if (cache != null) {
cache.removeAll();
}
// get the reports cache "excelExportCache", declared in ehcache.xml
Cache excelExportCache = cm.getCache("excelExportCache");
if (excelExportCache != null) {
excelExportCache.removeAll();
}
}
Aggregations