From 54369c08dc41b46bdbf647768f04c9e009e878d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=81=E6=98=BE=E4=BC=98?= <237809796@qq.com> Date: Mon, 8 May 2023 16:29:05 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=EF=BC=9Aredis=20=E6=8F=92?= =?UTF-8?q?=E4=BB=B6=E5=AF=86=E7=A0=81=E8=A7=A3=E5=AF=86=E5=A4=84=E7=90=86?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/org/redkalex/cache/redis/RedisCacheSource.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/org/redkalex/cache/redis/RedisCacheSource.java b/src/org/redkalex/cache/redis/RedisCacheSource.java index eef81e0..0e7211c 100644 --- a/src/org/redkalex/cache/redis/RedisCacheSource.java +++ b/src/org/redkalex/cache/redis/RedisCacheSource.java @@ -28,6 +28,7 @@ import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutorService; import java.util.concurrent.TimeUnit; import java.util.concurrent.locks.ReentrantLock; +import java.util.function.Function; import java.util.logging.Level; import java.util.logging.Logger; @@ -147,6 +148,10 @@ public class RedisCacheSource extends AbstractRedisSource { int maxconns = conf.getIntValue(CACHE_SOURCE_MAXCONNS, urlmaxconns); int pipelines = conf.getIntValue(CACHE_SOURCE_PIPELINES, urlpipelines); RedisCacheClient old = this.client; + + if (passwordDecoder != null) { + password = passwordDecoder.apply(password); + } this.client = new RedisCacheClient(resourceName(), ioGroup, resourceName() + "." + db, new ClientAddress(address), maxconns, pipelines, password == null || password.isEmpty() ? null : new RedisCacheReqAuth(password), db > 0 ? new RedisCacheReqDB(db) : null); if (old != null) { @@ -1787,4 +1792,10 @@ public class RedisCacheSource extends AbstractRedisSource { public Map> getCollectionMap(final boolean set, final Type componentType, String... keys) { return (Map) getCollectionMapAsync(set, componentType, keys).join(); } + + private static Function passwordDecoder = null; + + public static void setPasswordDecoder(Function decoder) { + passwordDecoder = decoder; + } }