Add RedisTemplate methods for executing Redis scripts

DATAREDIS-199
This commit is contained in:
Jennifer Hickey
2013-08-04 16:43:00 -07:00
parent faa78cdfaa
commit 7d387ab529
19 changed files with 914 additions and 1 deletions

View File

@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="lettuceConnectionFactory "
class="org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory">
<property name="hostName">
<bean class="org.springframework.data.redis.SettingsUtils" factory-method="getHost" />
</property>
<property name="port">
<bean class="org.springframework.data.redis.SettingsUtils" factory-method="getPort" />
</property>
</bean>
</beans>

View File

@@ -0,0 +1,7 @@
local size=redis.call('LLEN',KEYS[1])
local max = math.min(size,ARGV[1])
local t={}
for variable = 1, max, 1 do
table.insert(t,redis.call('RPOP',KEYS[1]))
end
return t

View File

@@ -0,0 +1,7 @@
local current = redis.call('GET', KEYS[1])
if current == ARGV[1]
then
redis.call('SET', KEYS[1], ARGV[2])
return true
end
return false

View File

@@ -0,0 +1,5 @@
if redis.call("EXISTS",KEYS[1]) == 1 then
return redis.call("INCR",KEYS[1])
else
return nil
end

View File

@@ -0,0 +1,4 @@
local t={}
table.insert(t,redis.call('RPOP',KEYS[1]))
table.insert(t,redis.call('LLEN',KEYS[1]))
return t