From 9b231dbb1019fc36436376ddea368cf3ace8395e Mon Sep 17 00:00:00 2001 From: "Dylan.Liu" Date: Sat, 21 Dec 2019 20:26:36 +0800 Subject: [PATCH] =?UTF-8?q?=20DEC-11501=20=20=E3=80=9010.0.5=E3=80=91?= =?UTF-8?q?=E3=80=90=E9=9B=86=E7=BE=A4=E3=80=91=E3=80=90Redis=E5=93=A8?= =?UTF-8?q?=E5=85=B5=E6=A8=A1=E5=BC=8F=E6=8F=92=E4=BB=B6=E3=80=91=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E6=96=B0=E4=B8=BB=E8=8A=82=E7=82=B9=E5=90=8D=E4=B9=8B?= =?UTF-8?q?=E5=90=8E=EF=BC=8C=E9=9B=86=E7=BE=A4=E8=8A=82=E7=82=B9=E5=BC=82?= =?UTF-8?q?=E5=B8=B8=20=E5=A2=9E=E5=8A=A0=E4=B8=80=E4=B8=AA=E5=8F=AF?= =?UTF-8?q?=E4=BB=A5=E4=BD=BF=E5=A4=9A=E4=B8=AA=E9=85=8D=E7=BD=AE=E7=BC=93?= =?UTF-8?q?=E5=AD=98=E5=A4=B1=E6=95=88=E7=9A=84=20modify=20=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fanruan/api/conf/ConfigurationKit.java | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/src/main/java/com/fanruan/api/conf/ConfigurationKit.java b/src/main/java/com/fanruan/api/conf/ConfigurationKit.java index 6f7ccb1..b4bbacf 100644 --- a/src/main/java/com/fanruan/api/conf/ConfigurationKit.java +++ b/src/main/java/com/fanruan/api/conf/ConfigurationKit.java @@ -60,6 +60,26 @@ public class ConfigurationKit { }); } + /** + * 在一个事务中修改配置 + * 支持 让 configType, configTypes 缓存失效 + * + * @param configType 配置类 + * @param runner 执行器 + * @param configTypes 配置类(所有的配置类都会缓存失效) + */ + public static void modify(Runner runner, Class configType, Class... configTypes) { + Configurations.modify(new WorkerFacade(configType, configTypes) { + @Override + public void run() { + if (runner != null) { + runner.run(); + } + } + }); + } + + /** * 在一个事务中修改配置 * @@ -81,4 +101,29 @@ public class ConfigurationKit { } Configurations.modify(facade); } + + /** + * 在一个事务中修改配置 + * 支持 让 configType, configTypes 失效 + * + * @param configType 配置类 + * @param runner 执行器 + * @param callBack 事务回调 + * @param configTypes 配置类(所有的配置类都会缓存失效) + */ + public static void modify(Runner runner, WorkerCallBack callBack, Class configType, Class... configTypes) { + WorkerFacade facade = new WorkerFacade(configType, configTypes) { + @Override + public void run() { + if (runner != null) { + runner.run(); + } + } + }; + if (callBack != null) { + facade.addCallBack(callBack); + } + Configurations.modify(facade); + } + }