增加Cached.localLimit属性
This commit is contained in:
@@ -53,6 +53,13 @@ public class CachedManagerTest {
|
||||
bean.setRemark(bean.getRemark() + "-新备注");
|
||||
Assertions.assertEquals(
|
||||
manager.localGet("name", bean.getName(), CachingBean.class).toString(), json);
|
||||
|
||||
manager.localGetSet("group", "key1", CachingBean.class, true, 2, expire, () -> new CachingBean("v1", "r1"));
|
||||
Utility.sleep(2);
|
||||
manager.localGetSet("group", "key2", CachingBean.class, true, 2, expire, () -> new CachingBean("v2", "r2"));
|
||||
Utility.sleep(2);
|
||||
manager.localGetSet("group", "key3", CachingBean.class, true, 2, expire, () -> new CachingBean("v3", "r3"));
|
||||
Assertions.assertEquals(2, manager.getLocalSource().getKeyCount("group"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -71,6 +78,7 @@ public class CachedManagerTest {
|
||||
"name",
|
||||
String.class,
|
||||
false,
|
||||
0,
|
||||
localExpire,
|
||||
remoteExpire,
|
||||
() -> bean.getName());
|
||||
@@ -82,7 +90,7 @@ public class CachedManagerTest {
|
||||
}
|
||||
Assertions.assertEquals(1, ParallelBean.c1.get());
|
||||
Utility.sleep(200);
|
||||
manager.bothGetSet("name", "name", String.class, false, localExpire, remoteExpire, () -> bean.getName());
|
||||
manager.bothGetSet("name", "name", String.class, false, 0, localExpire, remoteExpire, () -> bean.getName());
|
||||
Assertions.assertEquals(1, ParallelBean.c1.get());
|
||||
Utility.sleep(300);
|
||||
{
|
||||
@@ -94,6 +102,7 @@ public class CachedManagerTest {
|
||||
"name",
|
||||
String.class,
|
||||
false,
|
||||
0,
|
||||
localExpire,
|
||||
remoteExpire,
|
||||
() -> bean.getName());
|
||||
@@ -123,6 +132,15 @@ public class CachedManagerTest {
|
||||
|
||||
private String remark;
|
||||
|
||||
public CachingBean() {
|
||||
//
|
||||
}
|
||||
|
||||
public CachingBean(String name, String remark) {
|
||||
this.name = name;
|
||||
this.remark = remark;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@@ -50,6 +50,7 @@ public class _DynLocalCacheInstance extends CachedInstance {
|
||||
key = "name",
|
||||
nullable = false,
|
||||
timeUnit = TimeUnit.SECONDS,
|
||||
localLimit = "-1",
|
||||
remoteExpire = "-1",
|
||||
localExpire = "30")
|
||||
public String getName() {
|
||||
@@ -68,6 +69,7 @@ public class _DynLocalCacheInstance extends CachedInstance {
|
||||
key = "#{id}_#{files.one}",
|
||||
nullable = false,
|
||||
timeUnit = TimeUnit.SECONDS,
|
||||
localLimit = "-1",
|
||||
remoteExpire = "60",
|
||||
localExpire = "30")
|
||||
public File getInfo(CachedInstance.ParamBean bean, int id, List<String> idList, Map<String, File> files) {
|
||||
@@ -87,6 +89,7 @@ public class _DynLocalCacheInstance extends CachedInstance {
|
||||
key = "name",
|
||||
nullable = false,
|
||||
timeUnit = TimeUnit.SECONDS,
|
||||
localLimit = "-1",
|
||||
remoteExpire = "-1",
|
||||
localExpire = "30")
|
||||
public CompletableFuture<String> getNameAsync() {
|
||||
@@ -105,6 +108,7 @@ public class _DynLocalCacheInstance extends CachedInstance {
|
||||
key = "#{id}_#{files.one}",
|
||||
nullable = false,
|
||||
timeUnit = TimeUnit.SECONDS,
|
||||
localLimit = "-1",
|
||||
remoteExpire = "60",
|
||||
localExpire = "30")
|
||||
public CompletableFuture<Map<String, Integer>> getInfo2Async(
|
||||
@@ -128,6 +132,7 @@ public class _DynLocalCacheInstance extends CachedInstance {
|
||||
key = "name",
|
||||
nullable = false,
|
||||
timeUnit = TimeUnit.SECONDS,
|
||||
localLimit = "-1",
|
||||
remoteExpire = "60",
|
||||
localExpire = "30")
|
||||
public CompletableFuture<String> getName2Async() throws IOException, InstantiationException {
|
||||
@@ -146,6 +151,7 @@ public class _DynLocalCacheInstance extends CachedInstance {
|
||||
key = "#{id}_#{files.one}",
|
||||
nullable = false,
|
||||
timeUnit = TimeUnit.SECONDS,
|
||||
localLimit = "-1",
|
||||
remoteExpire = "60",
|
||||
localExpire = "30")
|
||||
public CompletableFuture<File> getInfoAsync(
|
||||
@@ -166,6 +172,7 @@ public class _DynLocalCacheInstance extends CachedInstance {
|
||||
key = "name",
|
||||
nullable = false,
|
||||
timeUnit = TimeUnit.SECONDS,
|
||||
localLimit = "-1",
|
||||
remoteExpire = "60",
|
||||
localExpire = "30")
|
||||
public String getName2() throws RedkaleException {
|
||||
|
||||
Reference in New Issue
Block a user