class CacheResource {

	boolean clearCache() {
		boolean cleared = false;
		
		try {
			CacheConfiguration ehConfig = new CacheConfiguration()
				.name(cacheName)
				.memoryStoreEvictionPolicy(MemoryStoreEvictionPolicy.LRU)
				.persistence(new PersistenceConfiguration()
					.strategy(PersistenceConfiguration.Strategy.LOCALTEMPSWAP))
				.maxBytesLocalDisk(10, MemoryUnit.MEGABYTES)
				.maxBytesLocalHeap(1, MemoryUnit.MEGABYTES)
				.clearOnFlush(true);
			Configuration managerConfig = new Configuration()
				.diskStore(new DiskStoreConfiguration().path(cacheLocation))
				.dynamicConfig(false)
				.cache(ehConfig);
			CacheManager cacheManager = CacheManager.create(managerConfig);
			Ehcache ehcache = cacheManager.getEhcache(cacheName);
			if (ehcache != null) {
				ehcache.flush();
				ehcache.removeAll();
				cleared = true;
			} else {
				cleared = false;
			}
		} catch (Exception e) {
			log.debug("Unable to clear cache", e);
			cleared = false;
		}
		
		return cleared;
	}

}