Merge branch 'master' into 3.0.0

pull/1303/head
Nikita 7 years ago
commit 8a2a84eff8

@ -53,24 +53,25 @@ Features
Used by Used by
================================ ================================
[![S&P Global](https://redisson.org/assets/logos/client20.png "S&P Global")](https://www.spglobal.com/)    
[![SAP](https://redisson.org/assets/logos/client12.png "SAP")](http://www.sap.com/)     [![SAP](https://redisson.org/assets/logos/client12.png "SAP")](http://www.sap.com/)    
[![EA](https://redisson.org/assets/logos/client1.png "EA")](http://ea.com/)     [![EA](https://redisson.org/assets/logos/client1.png "EA")](http://ea.com/)    
[![BROOKHAVEN](https://redisson.org/assets/logos/client6.png "Brookhaven National Laboratory")](http://bnl.gov/)     [![BROOKHAVEN](https://redisson.org/assets/logos/client6.png "Brookhaven National Laboratory")](http://bnl.gov/)    
[![New Relic Synthetics](https://redisson.org/assets/logos/client3.png "New Relic Synthetics")](http://newrelic.com/synthetics)     [![New Relic Synthetics](https://redisson.org/assets/logos/client3.png "New Relic Synthetics")](http://newrelic.com/synthetics)    
[![Singtel](https://redisson.org/assets/logos/client5.png "New Relic Synthetics")](http://singtel.com/)     [![Singtel](https://redisson.org/assets/logos/client5.png "New Relic Synthetics")](http://singtel.com/)    
[![Netflix](https://redisson.org/assets/logos/client10.png "Netflix")](https://netflix.com/)     [![Netflix](https://redisson.org/assets/logos/client10.png "Netflix")](https://netflix.com/)
[![Baidu](https://redisson.org/assets/logos/client2.png "Baidu")](http://baidu.com/) [![Baidu](https://redisson.org/assets/logos/client2.png "Baidu")](http://baidu.com/)    
[![Infor](https://redisson.org/assets/logos/client4.png "Infor")](http://www.infor.com/)     [![Infor](https://redisson.org/assets/logos/client4.png "Infor")](http://www.infor.com/)    
[![Crimson Hexagon](https://redisson.org/assets/logos/client7.png "Crimson Hexagon")](https://www.crimsonhexagon.com/)     [![Crimson Hexagon](https://redisson.org/assets/logos/client7.png "Crimson Hexagon")](https://www.crimsonhexagon.com/)    
[![Datorama](https://redisson.org/assets/logos/client8.png "Datorama")](https://datorama.com/)     [![Datorama](https://redisson.org/assets/logos/client8.png "Datorama")](https://datorama.com/)   
[![OptionsHouse](https://redisson.org/assets/logos/client9.png "OptionsHouse")](https://www.optionshouse.com/)     [![Invaluable](https://redisson.org/assets/logos/client13.png "Invaluable")](http://www.invaluable.com/)   
[![Invaluable](https://redisson.org/assets/logos/client13.png "Invaluable")](http://www.invaluable.com/) [![Ticketmaster](https://redisson.org/assets/logos/client14.png "Ticketmaster")](http://www.ticketmaster.com/)
[![Ticketmaster](https://redisson.org/assets/logos/client14.png "Ticketmaster")](http://www.ticketmaster.com/)   
[![PANDORA](https://redisson.org/assets/logos/client15.png "PANDORA")](http://www.pandora.com/)    [![PANDORA](https://redisson.org/assets/logos/client15.png "PANDORA")](http://www.pandora.com/)   
[![ContaAzul](https://redisson.org/assets/logos/client18.png "ContaAzul")](https://contaazul.com/)    [![ContaAzul](https://redisson.org/assets/logos/client18.png "ContaAzul")](https://contaazul.com/)   
[![NAB](https://redisson.org/assets/logos/client11.png "NAB")](https://www.nab.com.au/) [![NAB](https://redisson.org/assets/logos/client11.png "NAB")](https://www.nab.com.au/)   
[![Alibaba](https://redisson.org/assets/logos/client19.png "Alibaba")](http://www.alibaba-inc.com)    [![Alibaba](https://redisson.org/assets/logos/client19.png "Alibaba")](http://www.alibaba-inc.com)   
[![SULAKE](https://redisson.org/assets/logos/client17.png "SULAKE")](http://www.sulake.com/) [![Flipkart](https://redisson.org/assets/logos/client21.png "Flipkart")](https://www.flipkart.com/)   
[![SULAKE](https://redisson.org/assets/logos/client17.png "SULAKE")](http://www.sulake.com/)   
Success stories Success stories

@ -949,6 +949,30 @@ public class RedissonLocalCachedMap<K, V> extends RedissonMap<K, V> implements R
cache.put(cacheKey, new CacheValue(entry.getKey(), entry.getValue())); cache.put(cacheKey, new CacheValue(entry.getKey(), entry.getValue()));
} }
} }
@Override
public void clearLocalCache() {
get(clearLocalCacheAsync());
}
@Override
public RFuture<Void> clearLocalCacheAsync() {
final RPromise<Void> result = new RedissonPromise<Void>();
RFuture<Long> future = invalidationTopic.publishAsync(new LocalCachedMapClear());
future.addListener(new FutureListener<Long>() {
@Override
public void operationComplete(Future<Long> future) throws Exception {
if (!future.isSuccess()) {
result.tryFailure(future.cause());
return;
}
result.trySuccess(null);
}
});
return result;
}
@Override @Override
public RFuture<Set<Entry<K, V>>> readAllEntrySetAsync() { public RFuture<Set<Entry<K, V>>> readAllEntrySetAsync() {

@ -65,12 +65,12 @@ public class LocalCachedMapOptions<K, V> extends MapOptions<K, V> {
NONE, NONE,
/** /**
* Invalidate cache entry across all LocalCachedMap instances on map entry change. * Invalidate cache entry across all LocalCachedMap instances on map entry change. Broadcasts map entry hash (16 bytes) to all instances.
*/ */
INVALIDATE, INVALIDATE,
/** /**
* Update cache entry across all LocalCachedMap instances on map entry change. * Update cache entry across all LocalCachedMap instances on map entry change. Broadcasts full map entry state (Key and Value objects) to all instances.
*/ */
UPDATE UPDATE

@ -27,10 +27,23 @@ package org.redisson.api;
* @param <V> map value * @param <V> map value
*/ */
public interface RLocalCachedMap<K, V> extends RMap<K, V>, RDestroyable { public interface RLocalCachedMap<K, V> extends RMap<K, V>, RDestroyable {
/** /**
* Pre-warm the cached values. Not guaranteed to load ALL values, but statistically * Pre-warm the cached values. Not guaranteed to load ALL values, but statistically
* will preload approximately all (all if no concurrent mutating activity) * will preload approximately all (all if no concurrent mutating activity)
* Intended for use with no-eviction caches where entire maps are locally cached * Intended for use with no-eviction caches where entire maps are locally cached
*/ */
public void preloadCache(); void preloadCache();
/**
* Clears local cache across all instances
*
* @return void
*/
RFuture<Void> clearLocalCacheAsync();
/**
* Clears local cache across all instances
*/
void clearLocalCache();
} }

@ -34,7 +34,7 @@ public class BaseMasterSlaveServersConfig<T extends BaseMasterSlaveServersConfig
/** /**
* Redis 'slave' node minimum idle connection amount for <b>each</b> slave node * Redis 'slave' node minimum idle connection amount for <b>each</b> slave node
*/ */
private int slaveConnectionMinimumIdleSize = 10; private int slaveConnectionMinimumIdleSize = 32;
/** /**
* Redis 'slave' node maximum connection pool size for <b>each</b> slave node * Redis 'slave' node maximum connection pool size for <b>each</b> slave node
@ -44,7 +44,7 @@ public class BaseMasterSlaveServersConfig<T extends BaseMasterSlaveServersConfig
/** /**
* Redis 'master' node minimum idle connection amount for <b>each</b> slave node * Redis 'master' node minimum idle connection amount for <b>each</b> slave node
*/ */
private int masterConnectionMinimumIdleSize = 10; private int masterConnectionMinimumIdleSize = 32;
/** /**
* Redis 'master' node maximum connection pool size * Redis 'master' node maximum connection pool size

@ -77,7 +77,7 @@ public class ReplicatedServersConfig extends BaseMasterSlaveServersConfig<Replic
return scanInterval; return scanInterval;
} }
/** /**
* Elasticache node scan interval in milliseconds * Replication group scan interval in milliseconds
* *
* @param scanInterval in milliseconds * @param scanInterval in milliseconds
* @return config * @return config

@ -45,7 +45,7 @@ public class SingleServerConfig extends BaseConfig<SingleServerConfig> {
/** /**
* Minimum idle Redis connection amount * Minimum idle Redis connection amount
*/ */
private int connectionMinimumIdleSize = 10; private int connectionMinimumIdleSize = 32;
/** /**
* Redis connection maximum pool size * Redis connection maximum pool size

@ -290,6 +290,37 @@ public class RedissonLocalCachedMapTest extends BaseMapTest {
assertThat(cache2.size()).isEqualTo(2); assertThat(cache2.size()).isEqualTo(2);
} }
@Test
public void testLocalCacheClear() throws InterruptedException {
LocalCachedMapOptions<String, Integer> options = LocalCachedMapOptions.<String, Integer>defaults()
.evictionPolicy(EvictionPolicy.LFU)
.cacheSize(5)
.syncStrategy(SyncStrategy.INVALIDATE);
RLocalCachedMap<String, Integer> map1 = redisson.getLocalCachedMap("test", options);
Cache<CacheKey, CacheValue> cache1 = Deencapsulation.getField(map1, "cache");
RLocalCachedMap<String, Integer> map2 = redisson.getLocalCachedMap("test", options);
Cache<CacheKey, CacheValue> cache2 = Deencapsulation.getField(map2, "cache");
map1.put("1", 1);
map1.put("2", 2);
assertThat(map2.get("1")).isEqualTo(1);
assertThat(map2.get("2")).isEqualTo(2);
assertThat(cache1.size()).isEqualTo(2);
assertThat(cache2.size()).isEqualTo(2);
map1.clearLocalCache();
Thread.sleep(50);
assertThat(cache1.size()).isZero();
assertThat(cache2.size()).isZero();
}
@Test @Test
public void testNoInvalidationOnRemove() throws InterruptedException { public void testNoInvalidationOnRemove() throws InterruptedException {
LocalCachedMapOptions<String, Integer> options = LocalCachedMapOptions.<String, Integer>defaults() LocalCachedMapOptions<String, Integer> options = LocalCachedMapOptions.<String, Integer>defaults()

Loading…
Cancel
Save