Scala 如何在Play 2.3.7中使用Redis

Scala 如何在Play 2.3.7中使用Redis,scala,playframework,redis,Scala,Playframework,Redis,我刚刚通过以下方式启用了Redis。在应用程序首次启动时,一切都可以正常编译,并加载Redis: [info] application - Redis Plugin enabled. Connecting to Redis on localhost:6379 to 0 with timeout 2000. [info] application - Redis Plugin pool configuration: redis.clients.jedis.JedisPoolConfig@287ab5

我刚刚通过以下方式启用了Redis。在应用程序首次启动时,一切都可以正常编译,并加载Redis:

[info] application - Redis Plugin enabled. Connecting to Redis on localhost:6379 to 0 with timeout 2000.
[info] application - Redis Plugin pool configuration: redis.clients.jedis.JedisPoolConfig@287ab5fe[maxTotal=8,maxIdle=8,minIdle=0,lifo=true,maxWaitMillis=-1,minEvictableIdleTimeMillis=60000,softMinEvictableIdleTimeMillis=1800000,numTestsPerEvictionRun=-1,evictionPolicyClassName=org.apache.commons.pool2.impl.DefaultEvictionPolicy,testOnBorrow=false,testOnReturn=false,testWhileIdle=true,timeBetweenEvictionRunsMillis=30000,blockWhenExhausted=true,jmxEnabled=true,jmxNamePrefix=pool]
。。。但是当我尝试像这样从我的应用程序访问缓存时

Cache.set(id, tokenTrace, (expiration.getMillis / 1000).asInstanceOf[Int])
。。。我得到以下警告:

[warn] application - could not deserialize key:ecbba6d3-3ef2-4bbe-a979-d0e68ffee9bd ex:redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool
redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool
at redis.clients.util.Pool.getResource(Pool.java:42)
at org.sedis.Pool.withJedisClient(sedis.scala:101)
at com.typesafe.plugin.RedisPlugin$$anon$1.get(RedisPlugin.scala:178)
at play.api.cache.Cache$.get(Cache.scala:80)
at services.auth.cache.CacheTokenTraceDaoComponent$CacheTokenTraceDao$$anonfun$remove$2.apply$mcI$sp(CacheTokenTraceDaoComponent.scala:70)
我错过什么了吗

编辑

TokenTrace类只跟踪JWT,如下所示:

class TokenTrace private(protected var json: JsValue) extends JsEntity
  with Serializable {

  def id = json as (__ \ 'id).readNullable[String]
  def id_= (v: Option[String]) = setValue((__ \ 'id), Json.toJson(v))
  def username = json as (__ \ 'username).readNullable[String]
  def username_= (v: Option[String]) = setValue((__ \ 'username), Json.toJson(v))
  def expirationTime = json as (__ \ 'expirationTime).read[DateTime]
  def expirationTime_= (v: DateTime) = setValue((__ \ 'expirationTime), Json.toJson(v))

  def copy(json: JsValue) = throw new UnsupportedOperationException
  override def toString = json.toString
} 

只是一个包含令牌id和过期时间的类。我的应用程序的授权系统基于JWT JSON Web令牌。。。我用来在数据库中存储令牌跟踪id+过期时间。现在的想法是使用Redis缓存令牌跟踪-那个类可以序列化吗?因为插件只支持字符串、Int、Long、Boolean和Serializable。不管怎样,只是让这个类可以序列化。。。但问题仍然存在:-刚刚添加到我的帖子-好的,现在它工作了。如前所述,我在application.conf中使TokenTrace可序列化并修复了redis.uri,如下所示:redis.uri=redis://localhost:6379 我错过了redis://前缀,因为我读到一篇文档说redis.uri=localhost就可以了。无论如何,非常感谢您的宝贵支持。