rediscala是Redis的Scala非堵塞客户端开发包,支持异步I/O操作。
示例代码:
importredis.RedisClientimportscala.concurrent.Awaitimportscala.concurrent.duration._importscala.concurrent.ExecutionContext.Implicits.globalobjectMainextendsApp{implicitvalakkaSystem=akka.actor.ActorSystem()valredis=RedisClient()valfuturePong=redis.ping()println("Pingsent!")futurePong.map(pong=>{println(s"Redisrepliedwitha$pong")})Await.result(futurePong,5seconds)akkaSystem.shutdown()}
评论