java - Enable Caching in Spring Data Redis -
i trying implement spring data redis , trying enable cache. think doing wrong. have tried reading docs , following still couldn't make work. pretty novice spring data redis. using 1.5.1-release jedis 2.6.2. function adding words:
public long addwordwithitsmeaningtodictionary (string word, string meaning) { long index = redistemplate.opsforlist().rightpush(word, meaning); return index; }
and 1 retrieving:
@cacheable("words") public list<string> getallthemeaningsforaword (string word) { list<string> meanings = redistemplate.opsforlist().range(word, 0, -1); system.out.println (word); return meanings; }
this understanding impelementation, first cache hit, if result found, fetch that, otherwise, bring word redis , store in cache. exception stacktrace:
exception in thread "main" org.springframework.dao.invaliddataaccessapiusageexception: wrongtype operation against key holding wrong kind of value; nested exception redis.clients.jedis.exceptions.jedisdataexception: wrongtype operation against key holding wrong kind of value @ org.springframework.data.redis.connection.jedis.jedisexceptionconverter.convert(jedisexceptionconverter.java:44) @ org.springframework.data.redis.connection.jedis.jedisexceptionconverter.convert(jedisexceptionconverter.java:36) @ org.springframework.data.redis.passthroughexceptiontranslationstrategy.translate(passthroughexceptiontranslationstrategy.java:37) @ org.springframework.data.redis.fallbackexceptiontranslationstrategy.translate(fallbackexceptiontranslationstrategy.java:37) @ org.springframework.data.redis.connection.jedis.jedisconnection.convertjedisaccessexception(jedisconnection.java:196) @ org.springframework.data.redis.connection.jedis.jedisconnection.get(jedisconnection.java:1102) @ org.springframework.data.redis.connection.defaultstringredisconnection.get(defaultstringredisconnection.java:282) @ org.springframework.data.redis.cache.rediscache$1.doinredis(rediscache.java:111) @ org.springframework.data.redis.cache.rediscache$1.doinredis(rediscache.java:105) @ org.springframework.data.redis.cache.rediscache$abstractrediscachecallback.doinredis(rediscache.java:367) @ org.springframework.data.redis.core.redistemplate.execute(redistemplate.java:191) @ org.springframework.data.redis.core.redistemplate.execute(redistemplate.java:153) @ org.springframework.data.redis.cache.rediscache.get(rediscache.java:104) @ org.springframework.data.redis.cache.rediscache.get(rediscache.java:90) @ org.springframework.cache.interceptor.cacheaspectsupport.findincaches(cacheaspectsupport.java:308) @ org.springframework.cache.interceptor.cacheaspectsupport.findcacheditem(cacheaspectsupport.java:279) @ org.springframework.cache.interceptor.cacheaspectsupport.execute(cacheaspectsupport.java:201) @ org.springframework.cache.interceptor.cacheaspectsupport.execute(cacheaspectsupport.java:181) @ org.springframework.cache.interceptor.cacheinterceptor.invoke(cacheinterceptor.java:60) @ org.springframework.aop.framework.reflectivemethodinvocation.proceed(reflectivemethodinvocation.java:179) @ org.springframework.aop.framework.cglibaopproxy$dynamicadvisedinterceptor.intercept(cglibaopproxy.java:644) @ com.ssc.dictionary.dao.dictionarydao$$enhancerbyspringcglib$$6e9ccfb0.getallthemeaningsforaword() @ com.ssc.dictionary.config.main.dictionary(main.java:36) @ com.ssc.dictionary.config.main.main(main.java:26) caused by: redis.clients.jedis.exceptions.jedisdataexception: wrongtype operation against key holding wrong kind of value @ redis.clients.jedis.protocol.processerror(protocol.java:113) @ redis.clients.jedis.protocol.process(protocol.java:138) @ redis.clients.jedis.protocol.read(protocol.java:192) @ redis.clients.jedis.connection.readprotocolwithcheckingbroken(connection.java:282) @ redis.clients.jedis.connection.getbinarybulkreply(connection.java:201) @ redis.clients.jedis.binaryjedis.get(binaryjedis.java:127) @ org.springframework.data.redis.connection.jedis.jedisconnection.get(jedisconnection.java:1100)
can tell, doing wrong? or if need enable cache before putting records in redis too?
Comments
Post a Comment