This commit is contained in:
Redkale
2017-03-17 09:26:44 +08:00
parent be61aef123
commit bb2f43c317
3 changed files with 11 additions and 6 deletions

View File

@@ -61,6 +61,11 @@ public class SncpTestService implements SncpTestIService {
return "result: " + bean;
}
public void queryResult(AsyncHandler<String, SncpTestBean> handler, @RpcAttachment SncpTestBean bean) {
System.out.println(Thread.currentThread().getName() + " handler 运行了queryResult方法");
if (handler != null) handler.completed("result: " + bean, bean);
}
@RpcMultiRun
public String updateBean(@RpcCall(CallAttribute.class) SncpTestBean bean) {
bean.setId(System.currentTimeMillis());

View File

@@ -36,10 +36,10 @@ public class CacheTestBean {
Attribute nameattr = Attribute.create(CacheTestBean.class, "name");
Attribute priceattr = Attribute.create(CacheTestBean.class, "price");
BiFunction<DataSource, Class, List> fullloader = (s, z) -> list;
Method method = EntityInfo.class.getDeclaredMethod("load", Class.class, int.class, boolean.class, Properties.class,
Method method = EntityInfo.class.getDeclaredMethod("load", Class.class, boolean.class, Properties.class,
DataSource.class, BiFunction.class);
method.setAccessible(true);
final EntityInfo<CacheTestBean> info = (EntityInfo<CacheTestBean>) method.invoke(null, CacheTestBean.class, 0, true, new Properties(), null, fullloader);
final EntityInfo<CacheTestBean> info = (EntityInfo<CacheTestBean>) method.invoke(null, CacheTestBean.class, true, new Properties(), null, fullloader);
EntityCache<CacheTestBean> cache = new EntityCache(info, null);
cache.fullLoad();

View File

@@ -44,10 +44,10 @@ public class TestSourceCache {
public static void main(String[] args) throws Exception {
final BiFunction<DataSource, Class, List> fullloader = (DataSource t, Class u) -> null;
Method method = EntityInfo.class.getDeclaredMethod("load", Class.class, int.class, boolean.class, Properties.class,
Method method = EntityInfo.class.getDeclaredMethod("load", Class.class, boolean.class, Properties.class,
DataSource.class, BiFunction.class);
method.setAccessible(true);
final EntityInfo<TestEntity> info = (EntityInfo<TestEntity>) method.invoke(null, TestEntity.class, 0, false, new Properties(), null, fullloader);
method.setAccessible(true);
final EntityInfo<TestEntity> info = (EntityInfo<TestEntity>) method.invoke(null, TestEntity.class, false, new Properties(), null, fullloader);
TestEntity[] entitys = new TestEntity[10_0000];
for (int i = 0; i < entitys.length; i++) {
entitys[i] = new TestEntity(i + 1, "用户_" + (i + 1));
@@ -86,7 +86,7 @@ public class TestSourceCache {
}
cdl.await();
e = System.currentTimeMillis() - s;
System.out.println("十万条数据中查询一页记录耗时: " + e / 1000.0 + "" + sheet); // CopyOnWriteArrayList 0.798 ConcurrentLinkedQueue 1.063
System.out.println("十万条数据中100并发查询一页循环10次记录耗时: " + e / 1000.0 + "" + sheet); // CopyOnWriteArrayList 0.798 ConcurrentLinkedQueue 1.063
}
@VirtualEntity