@Override public int size() { return this.remoteCache.size(); }
@Override public int size() { return delegate.size(); }
@Override public int size() { return this.remoteCache.size(); }
@Override protected Long size() { if (cache == null) return 0L; /** * TODO implement this. Which is the equivalent to * {@code cache.getAdvancedCache().getStats().getTotalNumberOfEntries();} */ return Long.valueOf(cache.size()); }
@Override public long getIndexSize(String index) { return this.infinispanContext.getCache(index).size(); }
@Override public long getIndexSize(String index) { return this.infinispanContext.getCache(index).size(); }
@Scheduled(fixedDelay = 2000) public void retrieveSize() { logger.info("Cache size " + cacheManager.administration().getOrCreateCache(Data.BASQUE_NAMES_CACHE, "default").size()); }
@Override public RemoteCacheSessionsLoaderContext computeLoaderContext(KeycloakSession session) { RemoteCache remoteCache = getRemoteCache(session); int sessionsTotal = remoteCache.size(); int ispnSegments = getIspnSegmentsCount(remoteCache); return new RemoteCacheSessionsLoaderContext(ispnSegments, sessionsPerSegment, sessionsTotal); }
public static void testSize(RemoteCache<String, String> remoteCache) { assertTrue(remoteCache.size() > 0); }
public static void testPutAllAsync(RemoteCache<String, String> remoteCache) throws Exception { remoteCache.clear(); Map<String, String> entries = new HashMap<String, String>(2); entries.put(KEY1, VALUE1); entries.put(KEY2, VALUE2); CompletableFuture<Void> f = remoteCache.putAllAsync(entries); f.get(ASYNC_TIMEOUT, TimeUnit.SECONDS); assertEquals(2, remoteCache.size()); }
public static void testPutAll(RemoteCache<String, String> remoteCache) { remoteCache.clear(); Map<String, String> entries = new HashMap<String, String>(2); entries.put(KEY1, VALUE1); entries.put(KEY2, VALUE2); remoteCache.putAll(entries); assertEquals(2, remoteCache.size()); }
private void writeToCache(RemoteCache<Integer, Transaction> remoteCache) { IntStream.range(0, 100).forEach(i -> remoteCache.put(i, new Transaction(i, "script" + i))); assertEquals("Cache should be populated", 100, remoteCache.size()); }
@Test public void testPutAllEviction() { RemoteCache<String, String> rc = remoteCacheManager.getCache("object"); rc.clear(); Map<String, String> entries = new HashMap<>(); entries.put("keyA", "A"); entries.put("keyB", "B"); entries.put("keyC", "C"); entries.put("keyD", "D"); rc.putAll(entries); assertEquals(3, rc.size()); }
@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())); }
@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()); }
private void testEviction(String cacheName) { RemoteCache<String, String> rc = remoteCacheManager.getCache(cacheName); rc.clear(); storeKeys(rc, "A", "B", "C"); assertTrue("B".equals(rc.get("keyB"))); assertTrue("A".equals(rc.get("keyA"))); rc.put("keyD", "D"); assertEquals(3, rc.size()); assertEquals("D", rc.get("keyD")); }
@Test public void testExecuteScript() throws Exception { uploadScript("test.js"); SecurityConfigurationHelper config = new SecurityConfigurationHelper("DIGEST-MD5"); config.forIspnServer(server1).withServerName("node0"); config.forCredentials(EXECUTOR_LOGIN, EXECUTOR_PASSWORD); RemoteCacheManager execRCM = new RemoteCacheManager(config.build(), true); RemoteCache cache = execRCM.getCache(CACHE_NAME); assertEquals(cache.size(), 0); Map<String, String> params = new HashMap<>(); params.put("key", "test_key"); params.put("value", "test_value"); int result = (Integer) cache.execute("test.js", params); assertEquals(result, 1); assertEquals(cache.size(), 1); assertEquals(cache.get("test_key"), "test_value"); execRCM.stop(); }
@Test public void testPutIfAbsent() { remoteCache.putIfAbsent("aKey", "aValue"); assertEquals(remoteCache.size(), 1); assertEquals(remoteCache.get("aKey"), "aValue"); assertNull(remoteCache.putIfAbsent("aKey", "anotherValue")); assertEquals(remoteCache.get("aKey"), "aValue"); }
@Test public void testPutIfAbsentWithLifespan() throws Exception { int lifespanInSecs = 1; remoteCache.putIfAbsent("aKey", "aValue", lifespanInSecs, TimeUnit.SECONDS, -1, TimeUnit.SECONDS); assertEquals(1, remoteCache.size()); assertEquals("aValue", remoteCache.get("aKey")); sleepForSecs(lifespanInSecs + 1); //verify the entry expired assertEquals(null, remoteCache.get("akey")); remoteCache.putIfAbsent("aKey", "aValue"); assertEquals(1, remoteCache.size()); assertEquals("aValue", remoteCache.get("aKey")); assertEquals(null, remoteCache.putIfAbsent("aKey", "anotherValue", lifespanInSecs, TimeUnit.SECONDS, -1, TimeUnit.SECONDS)); sleepForSecs(lifespanInSecs + 1); //verify the entry is still there because it was not put with lifespan since it had already existed assertEquals("aValue", remoteCache.get("aKey")); }
@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")); }