use of com.hazelcast.config.NearCacheConfig in project hazelcast by hazelcast.
the class NearCacheRecordStoreTestSupport method putAndRemoveRecord.
void putAndRemoveRecord(InMemoryFormat inMemoryFormat) {
NearCacheConfig nearCacheConfig = createNearCacheConfig(DEFAULT_NEAR_CACHE_NAME, inMemoryFormat);
NearCacheRecordStore<Integer, String> nearCacheRecordStore = createNearCacheRecordStore(nearCacheConfig, inMemoryFormat);
for (int i = 0; i < DEFAULT_RECORD_COUNT; i++) {
nearCacheRecordStore.put(i, null, "Record-" + i, null);
// ensure that they are stored
assertNotNull(nearCacheRecordStore.get(i));
}
assertEquals(DEFAULT_RECORD_COUNT, nearCacheRecordStore.size());
for (int i = 0; i < DEFAULT_RECORD_COUNT; i++) {
nearCacheRecordStore.invalidate(i);
assertNull(nearCacheRecordStore.get(i));
}
assertEquals(0, nearCacheRecordStore.size());
}
use of com.hazelcast.config.NearCacheConfig in project hazelcast by hazelcast.
the class ClientConfigXmlGeneratorTest method nearCache.
@Test
public void nearCache() {
NearCacheConfig expected = createNearCacheConfig(randomString()).setPreloaderConfig(new NearCachePreloaderConfig().setEnabled(true).setDirectory(randomString()).setStoreInitialDelaySeconds(randomInt()).setStoreIntervalSeconds(randomInt())).setEvictionConfig(new EvictionConfig().setEvictionPolicy(LFU).setMaxSizePolicy(USED_NATIVE_MEMORY_SIZE).setComparatorClassName(randomString()).setSize(randomInt()));
clientConfig.addNearCacheConfig(expected);
Map<String, NearCacheConfig> actual = newConfigViaGenerator().getNearCacheConfigMap();
assertMap(clientConfig.getNearCacheConfigMap(), actual);
}
use of com.hazelcast.config.NearCacheConfig in project hazelcast by hazelcast.
the class ClientConfigXmlGeneratorTest method createNearCacheConfig.
private NearCacheConfig createNearCacheConfig(String name) {
NearCacheConfig expected = new NearCacheConfig();
expected.setInMemoryFormat(InMemoryFormat.NATIVE).setSerializeKeys(true).setInvalidateOnChange(false).setTimeToLiveSeconds(randomInt()).setMaxIdleSeconds(randomInt()).setLocalUpdatePolicy(CACHE_ON_UPDATE).setName(name);
return expected;
}
use of com.hazelcast.config.NearCacheConfig in project hazelcast by hazelcast.
the class ClientMapNearCacheTest method testNearCache_whenInMemoryFormatIsNative_thenThrowIllegalArgumentException.
@Test(expected = InvalidConfigurationException.class)
public void testNearCache_whenInMemoryFormatIsNative_thenThrowIllegalArgumentException() {
NearCacheConfig nearCacheConfig = newNearCacheConfig().setInMemoryFormat(InMemoryFormat.NATIVE);
getNearCachedMapFromClient(nearCacheConfig);
}
use of com.hazelcast.config.NearCacheConfig in project hazelcast by hazelcast.
the class ClientMapNearCacheTest method testNearCacheGetAsyncTwice.
@Test
public void testNearCacheGetAsyncTwice() throws Exception {
NearCacheConfig nearCacheConfig = newNearCacheConfig().setInMemoryFormat(InMemoryFormat.OBJECT);
IMap<Integer, Integer> map = getNearCachedMapFromClient(nearCacheConfig);
map.getAsync(1).toCompletableFuture().get();
sleepMillis(1000);
assertNull(map.getAsync(1).toCompletableFuture().get());
}
Aggregations