From 318a8ff29921f81286c285a291c6593f555d5457 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=81=E6=98=BE=E4=BC=98?= <237809796@qq.com> Date: Thu, 25 May 2023 17:53:37 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=EF=BC=9A1=E3=80=81ZhubClient?= =?UTF-8?q?=20=E6=9E=84=E9=80=A0=E6=96=B9=E6=B3=95=EF=BC=8C=E6=94=AF?= =?UTF-8?q?=E6=8C=81=20new=20=E7=9A=84=E6=96=B9=E5=BC=8F=E5=88=9D=E5=A7=8B?= =?UTF-8?q?=E5=8C=96=E5=AE=9E=E4=BE=8B=EF=BC=88=E4=B8=80=E8=88=AC=E5=9C=A8?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E6=97=B6=E4=BD=BF=E7=94=A8=EF=BC=892?= =?UTF-8?q?=E3=80=81initClient=20=E6=96=B9=E6=B3=95=E9=80=BB=E8=BE=91?= =?UTF-8?q?=E5=BE=AE=E8=B0=83=EF=BC=8C=E7=A1=AE=E4=BF=9D=E5=AE=9E=E4=BE=8B?= =?UTF-8?q?=E5=AE=8C=E6=88=90=E5=88=9D=E5=A7=8B=E5=8C=96=E5=9C=A8=E6=89=A7?= =?UTF-8?q?=E8=A1=8C=E9=98=9F=E5=88=97=E6=95=B0=E6=8D=AE=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/com/zdemo/cachex/RedisTest.java | 9 ++++++--- src/com/zdemo/zhub/ZHubClient.java | 22 +++++++++++++--------- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/src/com/zdemo/cachex/RedisTest.java b/src/com/zdemo/cachex/RedisTest.java index 669529b..04cf9ed 100644 --- a/src/com/zdemo/cachex/RedisTest.java +++ b/src/com/zdemo/cachex/RedisTest.java @@ -3,8 +3,6 @@ package com.zdemo.cachex; import org.redkale.convert.json.JsonFactory; import org.redkale.util.AnyValue; -import java.util.Map; - public class RedisTest { static MyRedisCacheSource source = new MyRedisCacheSource(); @@ -115,9 +113,14 @@ public class RedisTest { System.out.println(source.getCollectionSize("sk")); // 2*/ - Map hms = source.getHms("supportusers", "5-kfeu0f", "xxxx", "3-0kbt7u8t", "95q- "); + /*Map hms = source.getHms("supportusers", "5-kfeu0f", "xxxx", "3-0kbt7u8t", "95q- "); hms.forEach((k, v) -> { System.out.println(k + " : " + v); + });*/ + + source.queryKeysStartsWith("ywb:").forEach(x -> { + System.out.println(x); + source.remove(x); }); diff --git a/src/com/zdemo/zhub/ZHubClient.java b/src/com/zdemo/zhub/ZHubClient.java index a86b606..f48c867 100644 --- a/src/com/zdemo/zhub/ZHubClient.java +++ b/src/com/zdemo/zhub/ZHubClient.java @@ -30,7 +30,6 @@ public class ZHubClient extends AbstractConsumer implements IConsumer, IProducer private String auth = ""; private String groupid = ""; - //private ReentrantLock lock = new ReentrantLock(); private Socket client; private OutputStream writer; private BufferedReader reader; @@ -41,16 +40,21 @@ public class ZHubClient extends AbstractConsumer implements IConsumer, IProducer private final LinkedBlockingQueue> rpcCallQueue = new LinkedBlockingQueue<>(); // RPC CALL MSG private final LinkedBlockingQueue sendMsgQueue = new LinkedBlockingQueue<>(); // SEND MSG - /*private BiConsumer threadBuilder = (r, n) -> { - for (int i = 0; i < n; i++) { - new Thread(() -> r.run()).start(); - } - };*/ - - /*private static boolean isFirst = true; - private boolean isMain = false;*/ private static Map mainHub = new HashMap<>(); // 127.0.0.1:1216 - ZHubClient + public ZHubClient() { + + } + + public ZHubClient(String name, Map attr) { + this.APP_NAME = name; + this.addr = attr.get("addr"); + this.groupid = attr.get("groupid"); + this.auth = attr.get("auth"); + + this.init(null); + } + @Override public void init(AnyValue config) { if (!preInit()) {