@Override public void clear() { this.remoteCache.clear(); }
/** * @see org.springframework.cache.Cache#clear() */ @Override public void clear() { this.nativeCache.clear(); }
@Override public void clear() { checkNotClosed(); cache.clear(); }
@Test public void testPutAllAsyncEviction() { RemoteCache<String, String> rc = remoteCacheManager.getCache("binary"); rc.clear(); Map<String, String> entries = new HashMap<>(); entries.put("keyA", "A"); entries.put("keyB", "B"); entries.put("keyC", "C"); entries.put("keyD", "D"); CompletableFuture res = rc.putAllAsync(entries); res.thenRun(() -> assertEquals(3, rc.size())); }
public static void testPutGetBulk(RemoteCache<String, String> remoteCache) { remoteCache.clear(); remoteCache.put(KEY1, VALUE1); remoteCache.put(KEY2, VALUE2); assertEquals(2, remoteCache.getBulk().size()); }
@AfterClass public static void release() { if (remoteCacheManager != null) { remoteCacheManager.getCache(CACHE_NAME).clear(); remoteCacheManager.stop(); } }
public static void testPutIfAbsentAsync(RemoteCache<String, String> remoteCache) throws Exception { remoteCache.clear(); remoteCache.put(KEY1, VALUE1); assertNull(remoteCache.putIfAbsentAsync(KEY1, "some test value").get(ASYNC_TIMEOUT, TimeUnit.SECONDS)); assertEquals(VALUE1, remoteCache.getAsync(KEY1).get(ASYNC_TIMEOUT, TimeUnit.SECONDS)); }
public void assertCleanCacheAndStoreHotrod(RemoteCache cache, final DBServer.TableManipulation table) throws Exception { cache.clear(); if (table.exists() && !table.getAllRows().isEmpty()) { table.deleteAllRows(); eventually(() -> table.getAllRows().isEmpty(), 10000); } }
@After public void tearDown() { if (remoteCache != null) { remoteCache.clear(); remoteCache.getRemoteCacheManager().stop(); } }
@Test public void testMultipleClients() { RemoteCache<String, String> rc1 = remoteCacheManager.getCache("off-heap"); RemoteCache<String, String> rc2 = remoteCacheManager.getCache("off-heap"); rc1.clear(); for (int i = 0; i < 1000; i++) { rc1.put(String.format("key1_%d", i), String.format("value1_%d", i)); rc2.put(String.format("key2_%d", i), String.format("value2_%d", i)); } assertEquals(3, rc1.size()); assertEquals(3, rc2.size()); }
@Before public void initialize() { if (remoteCacheManager == null) { Configuration config = createRemoteCacheManagerConfiguration(); remoteCacheManager = new RemoteCacheManager(config, true); } remoteCache = remoteCacheManager.getCache(testCache); remoteCache.clear(); }
@Test public void testStreamingScript() throws IOException { addScripts("stream.js"); RemoteCache<String, String> rc = remoteCacheManager.getCache("off-heap-default"); rc.clear(); rc.put("key1", "Lorem ipsum dolor sit amet"); rc.put("key2", "consectetur adipiscing elit"); rc.put("key3", "sed do eiusmod tempor incididunt ut labore et dolore magna aliqua"); Map<String, Long> result = rc.execute("stream.js", Collections.emptyMap()); assertEquals(19, result.size()); }
public static void testKeySet(RemoteCache<String, String> remoteCache) { remoteCache.clear(); remoteCache.put(KEY1, VALUE1); remoteCache.put(KEY2, VALUE2); assertEquals(2, remoteCache.keySet().size()); }
public static void testPutIfAbsent(RemoteCache<String, String> remoteCache) { remoteCache.clear(); remoteCache.put(KEY1, VALUE1); assertNull(remoteCache.putIfAbsent(KEY1, "some test value")); assertEquals(VALUE1, remoteCache.get(KEY1)); }
public static void testPutGetVersioned(RemoteCache<String, String> remoteCache) { remoteCache.clear(); remoteCache.put(KEY1, VALUE1); VersionedValue<String> v = remoteCache.getVersioned(KEY1); assertEquals(VALUE1, v.getValue()); assertTrue(v.getVersion() != 0); }
@Test public void testClear() { remoteCache.put("aKey", "aValue"); remoteCache.put("aKey2", "aValue"); remoteCache.clear(); assertTrue(!remoteCache.containsKey("aKey")); assertTrue(!remoteCache.containsKey("aKey2")); }
private void assertCleanCacheAndStore() throws Exception { mc.delete("k1"); mc.delete("k2"); mc.delete("k3"); cache.clear(); assertEquals(0, server1.getCacheManager(LOCAL_CACHE_MANAGER).getCache(LOCAL_CACHE_NAME).getNumberOfEntries()); assertEquals(0, server2.getCacheManager(LOCAL_CACHE_MANAGER).getDefaultCache().getNumberOfEntries()); } }
public static void testReplaceWithVersioned(RemoteCache<String, String> remoteCache) { remoteCache.clear(); remoteCache.put(KEY1, VALUE1); VersionedValue<String> v = remoteCache.getVersioned(KEY1); assertEquals(VALUE1, v.getValue()); long ver = v.getVersion(); remoteCache.replaceWithVersion(KEY1, VALUE2, ver); v = remoteCache.getVersioned(KEY1); assertEquals(VALUE2, v.getValue()); assertTrue(ver != v.getVersion()); }
@Test public void testEvictionNone() { RemoteCache<String, String> rc = remoteCacheManager.getCache("none"); rc.clear(); storeKeys(rc, "A", "B", "C"); rc.put("keyD", "D"); assertEquals(4, rc.size()); assertEquals("A", rc.get("keyA")); assertEquals("B", rc.get("keyB")); assertEquals("C", rc.get("keyC")); assertEquals("D", rc.get("keyD")); }