DefaultRedisScript类(Spring模版类)

文档地址 https://docs.spring.io/spring-data/redis/docs/current/api/org/springframework/data/redis/core/script/DefaultRedisScript.html
Package org.springframework.data.redis.core.script

Class DefaultRedisScript

java.lang.Object

Type Parameters:

  • T - The script result type. Should be one of Long, Boolean, List, or deserialized value type. Can be null if the script returns a throw-away status (i.e "OK")
    T - 脚本结果类型。应为 Long、Boolean、List 或反序列化值类型之一。如果脚本返回的是一次性状态(例如“OK”),则可以为 null。

All Implemented Interfaces: InitializingBean, RedisScript

public class DefaultRedisScript extends Object implements RedisScript, InitializingBean

RedisScript 的默认实现。委托底层 ScriptSource 检索脚本文本并检测脚本是否已被修改(因此需要重新计算 SHA1)。该类最好以单例形式使用,以避免每次脚本执行时都重新计算 SHA1。
Default implementation of RedisScript. Delegates to an underlying ScriptSource to retrieve script text and detect if script has been modified (and thus should have SHA1 re-calculated). This class is best used as a Singleton to avoid re-calculation of SHA1 on every script execution.

setLocation

public void setLocation(Resource scriptLocation)

Parameters:

  • scriptLocation - The location of the script

setResultType

public void setResultType(@Nullable Class resultType)

Parameters:

  • resultType - The script result type. Should be one of Long, Boolean, List, or deserialized value type. Can be null if the script returns a throw-away status (i.e "OK")
    脚本结果类型。应为 Long、Boolean、List 或反序列化值类型之一。如果脚本返回一次性状态(例如“OK”),则可以为 null。
posted @ 2025-04-13 18:51  kuki'  阅读(47)  评论(0)    收藏  举报