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
ConstructorDescriptionCreates a newDefaultRedisScript
DefaultRedisScript
(String script) Creates a newDefaultRedisScript
DefaultRedisScript
(String script, Class<T> resultType) Creates a newDefaultRedisScript
-
Method Summary
Modifier and TypeMethodDescriptionvoid
getSha1()
void
setLocation
(Resource scriptLocation) void
setResultType
(Class<T> resultType) void
setScriptSource
(ScriptSource scriptSource) void
setScriptText
(String scriptText) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods 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:
afterPropertiesSet
in interfaceInitializingBean
-
getSha1
- Specified by:
getSha1
in interfaceRedisScript<T>
- Returns:
- The SHA1 of the script, used for executing Redis evalsha command.
-
getResultType
- Specified by:
getResultType
in 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:
getScriptAsString
in 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 @{linkScriptSource
pointing to the script
-