DiskbackedCache implements CacheStrategy<CacheKey, CacheValue>, Closeable { @Override public void clear() { init(); try (Statement statement = dbConnection.createStatement()) { statement.execute(SQL_CLEAR); } catch (SQLException e) { throw new WroRuntimeException("Error clearing the cache", e); } defaultCache.clear(); } DiskbackedCache(int lruSize, String dbPathString);   DiskbackedCache(int lruSize); @Override void put(CacheKey key, CacheValue value); @Override CacheValue get(CacheKey key); @Override void clear(); @Override void destroy(); @Override void close(); static final String NAME; static final String DB_PROP_KEY; static final String SQL_PUT_CACHE_VALUE; static final String SQL_GET_QUERY; }
@Test public void testClear() throws Exception { CacheKey key = new CacheKey("groupName", ResourceType.CSS); CacheValue value = CacheValue.valueOf("rawContent", "hash"); try (DiskbackedCache cache = new DiskbackedCache(100)) { cache.put(key, value); CacheValue loaded = cache.get(key); assertEquals(value.getHash(), loaded.getHash()); assertEquals(value.getRawContent(), loaded.getRawContent()); assertArrayEquals(value.getGzippedContent(), loaded.getGzippedContent()); } }