use of com.hazelcast.config.CacheConfig in project hazelcast by hazelcast.
the class CacheBasicAbstractTest method expiryTimeShouldNotBeChangedOnUpdateWhenCreatedExpiryPolicyIsUsed.
// https://github.com/hazelcast/hazelcast/issues/7236
@Test
public void expiryTimeShouldNotBeChangedOnUpdateWhenCreatedExpiryPolicyIsUsed() {
final int CREATED_EXPIRY_TIME_IN_MSEC = 100;
Duration duration = new Duration(TimeUnit.MILLISECONDS, CREATED_EXPIRY_TIME_IN_MSEC);
CacheConfig<Integer, String> cacheConfig = new CacheConfig<Integer, String>();
cacheConfig.setExpiryPolicyFactory(CreatedExpiryPolicy.factoryOf(duration));
Cache<Integer, String> cache = createCache(cacheConfig);
cache.put(1, "value");
cache.put(1, "value");
sleepAtLeastMillis(CREATED_EXPIRY_TIME_IN_MSEC + 1);
assertNull(cache.get(1));
}
use of com.hazelcast.config.CacheConfig in project hazelcast by hazelcast.
the class CacheBasicAbstractTest method entryShouldNotBeExpiredWhenTimeUnitIsNullAndDurationIsZero.
@Test
public void entryShouldNotBeExpiredWhenTimeUnitIsNullAndDurationIsZero() {
Duration duration = new Duration(null, 0);
CacheConfig<Integer, String> cacheConfig = new CacheConfig<Integer, String>();
cacheConfig.setExpiryPolicyFactory(CreatedExpiryPolicy.factoryOf(duration));
Cache<Integer, String> cache = createCache(cacheConfig);
cache.put(1, "value");
sleepAtLeastMillis(1);
assertNotNull(cache.get(1));
}
use of com.hazelcast.config.CacheConfig in project hazelcast by hazelcast.
the class CacheClearTest method createCacheConfig.
@Override
protected <K, V> CacheConfig<K, V> createCacheConfig() {
CacheConfig cacheConfig = super.createCacheConfig();
cacheConfig.setBackupCount(INSTANCE_COUNT - 1);
return cacheConfig;
}
use of com.hazelcast.config.CacheConfig in project hazelcast by hazelcast.
the class CacheDestroyTest method test_cacheDestroyOperation.
@Test
public void test_cacheDestroyOperation() throws ExecutionException, InterruptedException {
final String CACHE_NAME = "MyCache";
final String FULL_CACHE_NAME = HazelcastCacheManager.CACHE_MANAGER_PREFIX + CACHE_NAME;
CachingProvider cachingProvider = HazelcastServerCachingProvider.createCachingProvider(getHazelcastInstance());
CacheManager cacheManager = cachingProvider.getCacheManager();
cacheManager.createCache(CACHE_NAME, new CacheConfig());
NodeEngineImpl nodeEngine1 = getNode(getHazelcastInstance()).getNodeEngine();
final ICacheService cacheService1 = nodeEngine1.getService(ICacheService.SERVICE_NAME);
InternalOperationService operationService1 = nodeEngine1.getOperationService();
NodeEngineImpl nodeEngine2 = getNode(hazelcastInstances[1]).getNodeEngine();
final ICacheService cacheService2 = nodeEngine2.getService(ICacheService.SERVICE_NAME);
assertNotNull(cacheService1.getCacheConfig(FULL_CACHE_NAME));
assertNotNull(cacheService2.getCacheConfig(FULL_CACHE_NAME));
// Invoke on single node and the operation is also forward to others nodes by the operation itself
operationService1.invokeOnTarget(ICacheService.SERVICE_NAME, new CacheDestroyOperation(FULL_CACHE_NAME), nodeEngine1.getThisAddress());
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
assertNull(cacheService1.getCacheConfig(FULL_CACHE_NAME));
assertNull(cacheService2.getCacheConfig(FULL_CACHE_NAME));
}
});
}
use of com.hazelcast.config.CacheConfig in project hazelcast by hazelcast.
the class CacheDestroyTest method createCacheConfig.
@Override
protected <K, V> CacheConfig<K, V> createCacheConfig() {
CacheConfig cacheConfig = super.createCacheConfig();
cacheConfig.setBackupCount(INSTANCE_COUNT - 1);
return cacheConfig;
}
Aggregations