Class DefaultRedisScript<T>
java.lang.Object
org.springframework.data.redis.core.script.DefaultRedisScript<T>
- 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")
- All Implemented Interfaces:
InitializingBean,RedisScript<T>
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.- Author:
- Jennifer Hickey, Christoph Strobl
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a newDefaultRedisScriptDefaultRedisScript(String script) Creates a newDefaultRedisScriptDefaultRedisScript(String script, Class<T> resultType) Creates a newDefaultRedisScript -
Method Summary
Modifier and TypeMethodDescriptionvoidgetSha1()voidsetLocation(Resource scriptLocation) voidsetResultType(Class<T> resultType) voidsetScriptSource(ScriptSource scriptSource) voidsetScriptText(String scriptText) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.data.redis.core.script.RedisScript
returnsRawValue
-
Constructor Details
-
DefaultRedisScript
public DefaultRedisScript()Creates a newDefaultRedisScript -
DefaultRedisScript
Creates a newDefaultRedisScript- Parameters:
script- must not be null.- Since:
- 2.0
-
DefaultRedisScript
Creates a newDefaultRedisScript- Parameters:
script- must not be null.resultType- can be null.
-
-
Method Details
-
afterPropertiesSet
public void afterPropertiesSet()- Specified by:
afterPropertiesSetin interfaceInitializingBean
-
getSha1
- Specified by:
getSha1in interfaceRedisScript<T>- Returns:
- The SHA1 of the script, used for executing Redis evalsha command.
-
getResultType
- Specified by:
getResultTypein interfaceRedisScript<T>- Returns:
- The script result type. Should be one of Long, Boolean, List, or deserialized value type. null if the script returns a throw-away status (i.e "OK").
-
getScriptAsString
- Specified by:
getScriptAsStringin interfaceRedisScript<T>- Returns:
- The script contents.
-
setResultType
- 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")
-
setScriptText
- Parameters:
scriptText- The script text
-
setLocation
- Parameters:
scriptLocation- The location of the script
-
setScriptSource
- Parameters:
scriptSource- A @{linkScriptSourcepointing to the script
-