Skip to content
This repository has been archived by the owner on Feb 9, 2019. It is now read-only.

Redis serialization error for Caching API #115

Open
jbhg opened this issue Jun 8, 2014 · 3 comments
Open

Redis serialization error for Caching API #115

jbhg opened this issue Jun 8, 2014 · 3 comments

Comments

@jbhg
Copy link

jbhg commented Jun 8, 2014

Cache API is working correctly when called explicitly (eg. in a method, Cache.getOrElse(...)), but not from the @Cached annotation.

Redis is configured correctly. From the logs:

[info] application - Redis Plugin enabled. Connecting to Redis on localhost:6379 with timeout 2000.
[info] application - Redis Plugin pool configuration: redis.clients.jedis.JedisPoolConfig@5037dd45[maxIdle=8,minIdle=0,maxActive=8,maxWait=-1,whenExhaustedAction=1,testOnBorrow=false,testOnReturn=false,testWhileIdle=true,timeBetweenEvictionRunsMillis=30000,numTestsPerEvictionRun=-1,minEvictableIdleTimeMillis=60000,softMinEvictableIdleTimeMillis=-1,lifo=true]

Plugin is:

550:com.typesafe.plugin.RedisPlugin

Trying to cache a Result (SimpleResult):

@Cached(key = "list")
public static Result list()
{
    return ok(index.render("message"));
}

Seeing error:

[warn] application - could not serialize key:list and value:SimpleResult(200, Map(Content-Type -> text/html;charset=utf-8)) ex:java.io.IOException: could not serialize: SimpleResult(200, Map(Content-Type -> text/html;charset=utf-8))

Play 2.2.2 with both "com.typesafe" %% "play-plugins-redis" % "2.2.0" in libraryDependencies and resolvers += "Sedis repository" at "http://pk11-scratch.googlecode.com/svn/trunk/"

Looks to me like the SimpleResult object is not being serialized correctly.

@wgriffiths
Copy link

Did you find a solution for this?

@jasonwill2433
Copy link

Anyone has a solution for this?

@jasonwill2433
Copy link

I believe, the Redis play plugin doesn't have a @cached helper.

By referring to Play documentation: https://www.playframework.com/documentation/2.4.x/JavaCache#Caching-HTTP-responses, I can easily write a customized action composition to handle this. Remember that "Play HTTP Result instances are safe to cache and reuse later."

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants