Scredis Redis 的 Scala 客户端开源项目

我要开发同款
匿名用户2016年03月01日
23阅读
开发技术Scala
所属分类数据库驱动程序、数据库相关
授权协议Apache

作品详情

Scredis是一个Redis的Scala客户端开发包。基于Akka构建,特点是Reactive、非堵塞以及超级快。

示例代码:

import scredis._import scala.util.{ Success, Failure }// Creates a Redis instance with default configuration.// See reference.conf for the complete list of configurable parameters.val redis = Redis()// Import internal ActorSystem's dispatcher (execution context) to register callbacksimport redis.dispatcher// Executing a non-blocking command and registering callbacks on the returned Futureredis.hGetAll("my-hash") onComplete {  case Success(content) => println(content)  case Failure(e) => e.printStackTrace()}// Executes a blocking command using the internal, lazily initialized BlockingClientredis.blocking.blPop(0, "queue")// Subscribes to a Pub/Sub channel using the internal, lazily initialized SubscriberClientredis.subscriber.subscribe("My Channel") {  case message @ PubSubMessage.Message(channel, messageBytes) => println(    message.readAs[String]()  )  case PubSubMessage.Subscribe(channel, subscribedChannelsCount) => println(    s"Successfully subscribed to $channel"  )}// Shutdown all initialized internal clients along with the ActorSystemredis.quit()
查看全文
声明:本文仅代表作者观点,不代表本站立场。如果侵犯到您的合法权益,请联系我们删除侵权资源!如果遇到资源链接失效,请您通过评论或工单的方式通知管理员。未经允许,不得转载,本站所有资源文章禁止商业使用运营!
下载安装【程序员客栈】APP
实时对接需求、及时收发消息、丰富的开放项目需求、随时随地查看项目状态

评论