FormatterCache { public void clear() throws IOException, SQLException { final Lock writeLock = lock.writeLock(); try { writeLock.lock(); this.memoryCache.invalidateAll(); this.persistentStore.clear(); } finally { writeLock.unlock(); } } FormatterCache(PersistentStore persistentStore, int memoryCacheSize, int maxStoreRequests);  FormatterCache(PersistentStore persistentStore, int memoryCacheSize, int maxStoreRequests,
                          CacheConfig cacheConfig, ExecutorService executor);  FormatterCache(PersistentStore persistentStore, int memoryCacheSize, int maxStoreRequests, CacheConfig config); @PreDestroy void shutdown(); void remove(Key key); @Nullable byte[] get(Key key, Validator validator, Callable<StoreInfoAndDataLoadResult> loader,
                      boolean writeToStoreInCurrentThread); @Nullable byte[] getPublished(Key key); synchronized void removeAll(int metadataId); void clear();  }
@Test public void testClear() throws Exception { final MemoryPersistentStore persistentStore = new MemoryPersistentStore(); this.formatterCache = new FormatterCache(persistentStore, 100, 5000); final boolean hideWithheld = true; final long changeDate = new Date().getTime(); final Key key = new Key(1, "eng", FormatType.html, "full_view", hideWithheld, FormatterWidth._100); final Key key2 = new Key(2, "eng", FormatType.html, "full_view", hideWithheld, FormatterWidth._100); formatterCache.get(key, new ChangeDateValidator(changeDate), new TestLoader("result", changeDate, false), true); formatterCache.get(key2, new ChangeDateValidator(changeDate), new TestLoader("result1", changeDate, false), true); formatterCache.clear(); assertArrayEquals("newVal1".getBytes(Constants.CHARSET), formatterCache.get(key, new ChangeDateValidator(changeDate), new TestLoader("newVal1", changeDate, false), true)); assertArrayEquals("newVal2".getBytes(Constants.CHARSET), formatterCache.get(key2, new ChangeDateValidator(changeDate), new TestLoader("newVal2", changeDate, false), true)); }