Class RedisCaptchaStore.Builder
java.lang.Object
cloud.opencode.base.captcha.store.RedisCaptchaStore.Builder
- Enclosing class:
RedisCaptchaStore
Builder for RedisCaptchaStore.
RedisCaptchaStore的构建器。
- Since:
- JDK 25, opencode-base-captcha V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()Builds the RedisCaptchaStore.Sets the Redis deleter function.existsChecker(Function<String, Boolean> existsChecker) Sets the Redis exists checker function.getAndRemoveCommand(Function<String, String> getAndRemover) Sets the atomic get-and-remove command for CAPTCHA validation.Sets the Redis getter function.Sets the key prefix.setter(RedisCaptchaStore.RedisSetter setter) Sets the Redis setter function.
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
keyPrefix
Sets the key prefix. 设置键前缀。- Parameters:
keyPrefix- the key prefix | 键前缀- Returns:
- this builder | 此构建器
-
setter
Sets the Redis setter function. 设置Redis setter函数。- Parameters:
setter- the setter | setter- Returns:
- this builder | 此构建器
-
getter
Sets the Redis getter function. 设置Redis getter函数。- Parameters:
getter- the getter | getter- Returns:
- this builder | 此构建器
-
deleter
Sets the Redis deleter function. 设置Redis deleter函数。- Parameters:
deleter- the deleter | deleter- Returns:
- this builder | 此构建器
-
existsChecker
Sets the Redis exists checker function. 设置Redis exists检查函数。- Parameters:
existsChecker- the exists checker | exists检查器- Returns:
- this builder | 此构建器
-
getAndRemoveCommand
Sets the atomic get-and-remove command for CAPTCHA validation. 设置用于验证码验证的原子获取并移除命令。This function should atomically retrieve and delete a value by key, equivalent to Redis
GETDEL(available since Redis 6.2). When provided,RedisCaptchaStore.getAndRemove(String)will use this function instead of the non-atomic GET+DEL fallback, preventing double-validation of CAPTCHAs under concurrent access.此函数应按键原子地获取并删除值,等同于 Redis
GETDEL(Redis 6.2 起可用)。 提供后,RedisCaptchaStore.getAndRemove(String)将使用此函数 而非非原子的 GET+DEL 回退方案,防止并发访问下的验证码重复验证。Usage Example | 使用示例:
// With Jedis (Redis 6.2+) .getAndRemoveCommand(key -> { try (Jedis jedis = pool.getResource()) { return jedis.getDel(key); } })- Parameters:
getAndRemover- the atomic get-and-delete function | 原子获取并删除函数- Returns:
- this builder | 此构建器
-
build
Builds the RedisCaptchaStore. 构建RedisCaptchaStore。- Returns:
- the store | 存储
-