lua - spring redis running script : how to pass expiry time value -


i use lua script:

local lock = redis.call('get', keys[1]) if not lock         return redis.call('setex', keys[1], argv[1] ,argv[2] ); end return false 

from spring boot application use call redis script

defaultredisscript<boolean> redisscript = new defaultredisscript<boolean>(); redisscript.setscriptsource(new resourcescriptsource(new classpathresource("checkandset2.lua"))); redisscript.setresulttype(boolean.class); system.out.println(redistemplate.execute(redisscript , collections.singletonlist("value123"),"10" ,"key123")); 

i exception :

java.lang.classcastexception: java.lang.long cannot cast java.lang.string @ org.springframework.data.redis.serializer.stringredisserializer.serialize(stringredisserializer.java:32) @ org.springframework.data.redis.core.script.defaultscriptexecutor.keysandargs(defaultscriptexecutor.java:116) @ org.springframework.data.redis.core.script.defaultscriptexecutor$1.doinredis(defaultscriptexecutor.java:63) @ org.springframework.data.redis.core.redistemplate.execute(redistemplate.java:202) @ org.springframework.data.redis.core.redistemplate.execute(redistemplate.java:164) @ org.springframework.data.redis.core.redistemplate.execute(redistemplate.java:152) @ org.springframework.data.redis.core.script.defaultscriptexecutor.execute(defaultscriptexecutor.java:60) @ org.springframework.data.redis.core.script.defaultscriptexecutor.execute(defaultscriptexecutor.java:54) @ org.springframework.data.redis.core.redistemplate.execute(redistemplate.java:298) @ com.masary.ledger.resisscripttestclass.msisdnjustrechargedexception(resisscripttestclass.java:34) @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(unknown source) @ sun.reflect.delegatingmethodaccessorimpl.invoke(unknown source) @ java.lang.reflect.method.invoke(unknown source) @ org.eclipse.jdt.internal.junit.runner.remotetestrunner.main(remotetestrunner.java:192) 

when use

system.out.println(redistemplate.execute(redisscript , collections.singletonlist("value123"),new long(10) ,"key123"));

i exception

     org.springframework.data.redis.redissystemexception: unknown redis exception; nested exception java.lang.classcastexception: [b cannot cast java.lang.long         @ org.springframework.data.redis.fallbackexceptiontranslationstrategy.getfallback(fallbackexceptiontranslationstrategy.java:48)         @ org.springframework.data.redis.fallbackexceptiontranslationstrategy.translate(fallbackexceptiontranslationstrategy.java:38)         @ org.springframework.data.redis.connection.jedis.jedisconnection.convertjedisaccessexception(jedisconnection.java:212)         @ org.springframework.data.redis.connection.jedis.jedisconnection.evalsha(jedisconnection.java:3173)         @ org.springframework.data.redis.connection.jedis.jedisconnection.evalsha(jedisconnection.java:3158)         @ org.springframework.data.redis.connection.defaultstringredisconnection.evalsha(defaultstringredisconnection.java:1374)         @ sun.reflect.nativemethodaccessorimpl.invoke0(native method)         @ sun.reflect.nativemethodaccessorimpl.invoke(unknown source)         @ sun.reflect.delegatingmethodaccessorimpl.invoke(unknown source)         @ java.lang.reflect.method.invoke(unknown source)         @ org.springframework.data.redis.core.closesuppressinginvocationhandler.invoke(closesuppressinginvocationhandler.java:57)         @ com.sun.proxy.$proxy182.evalsha(unknown source)         @ org.springframework.data.redis.core.script.defaultscriptexecutor.eval(defaultscriptexecutor.java:81)         @ org.springframework.data.redis.core.script.defaultscriptexecutor$1.doinredis(defaultscriptexecutor.java:71)         @ org.springframework.data.redis.core.redistemplate.execute(redistemplate.java:202)         @ org.springframework.data.redis.core.redistemplate.execute(redistemplate.java:164)         @ org.springframework.data.redis.core.redistemplate.execute(redistemplate.java:152)         @ org.springframework.data.redis.core.script.defaultscriptexecutor.execute(defaultscriptexecutor.java:60)         @ org.springframework.data.redis.core.script.defaultscriptexecutor.execute(defaultscriptexecutor.java:54)         @ org.springframework.data.redis.core.redistemplate.execute(redistemplate.java:298)         @ com.masary.ledger.resisscripttestclass.msisdnjustrechargedexception(resisscripttestclass.java:34)         @ sun.reflect.nativemethodaccessorimpl.invoke0(native method)         @ sun.reflect.nativemethodaccessorimpl.invoke(unknown source)         @ sun.reflect.delegatingmethodaccessorimpl.invoke(unknown source)         @ java.lang.reflect.method.invoke(unknown source) . .     caused by: java.lang.classcastexception: [b cannot cast java.lang.long         @ org.springframework.data.redis.connection.jedis.jedisscriptreturnconverter.convert(jedisscriptreturnconverter.java:53)         @ org.springframework.data.redis.connection.jedis.jedisconnection.evalsha(jedisconnection.java:3171)         ... 46 more 

any advice how can pass expiry time value lua script?

i'm newbie myself, , having similar problem. try sending string "10", instead of long. worked me.


Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -