- 1、增加接口类 StoreCacheKeyPrefix,用于处理 DefaultImageCaptchaApplication 的缓存 key 处理

- 2、DefaultImageCaptchaApplication 中的缓存 key 处理修改为 接口,便于扩展使用
- 3、DefaultImageCaptchaApplication的构建器 TACBuilder 中增加对 StoreCacheKeyPrefix 的支持
This commit is contained in:
chxlay
2025-11-11 14:55:12 +08:00
parent a46cb7d5fd
commit a323c2b262
3 changed files with 42 additions and 4 deletions
@@ -1,6 +1,7 @@
package cloud.tianai.captcha.application;
import cloud.tianai.captcha.cache.CacheStore;
import cloud.tianai.captcha.cache.StoreCacheKeyPrefix;
import cloud.tianai.captcha.cache.impl.LocalCacheStore;
import cloud.tianai.captcha.generator.ImageCaptchaGenerator;
import cloud.tianai.captcha.generator.ImageTransform;
@@ -29,6 +30,7 @@ public class TACBuilder {
private ImageCaptchaProperties prop = new ImageCaptchaProperties();
private ResourceStore resourceStore;
private ImageTransform imageTransform;
private StoreCacheKeyPrefix cacheKeyPrefix;
// private List<FontWrapper> fontWrappers = new ArrayList<>();
public static TACBuilder builder() {
@@ -75,6 +77,10 @@ public class TACBuilder {
return this;
}
public TACBuilder setCacheKeyPrefix(StoreCacheKeyPrefix cacheKeyPrefix) {
this.cacheKeyPrefix = cacheKeyPrefix;
return this;
}
public TACBuilder addFont(Resource resource) {
this.addResource(FontCache.FONT_TYPE, resource);
return this;
@@ -148,7 +154,8 @@ public class TACBuilder {
if (interceptor == null) {
interceptor = EmptyCaptchaInterceptor.INSTANCE;
}
DefaultImageCaptchaApplication application = new DefaultImageCaptchaApplication(generator, validator, cacheStore, prop, interceptor);
// 增加前缀处理接口
DefaultImageCaptchaApplication application = new DefaultImageCaptchaApplication(generator, validator, cacheStore, prop, interceptor, cacheKeyPrefix);
return application;
}
}