文件名称:Redis的Scala客户端Scredis.zip
文件大小:138KB
文件格式:ZIP
更新时间:2022-08-05 22:23:15
开源项目
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 callbacks import redis.dispatcher // Executing a non-blocking command and registering callbacks on the returned Future redis.hGetAll("my-hash") onComplete { case Success(content) => println(content) case Failure(e) => e.printStackTrace() } // Executes a blocking command using the internal, lazily initialized BlockingClient redis.blocking.blPop(0, "queue") // Subscribes to a Pub/Sub channel using the internal, lazily initialized SubscriberClient redis.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 ActorSystem redis.quit() 标签:Scredis redis
【文件预览】:
scredis-master
----NOTICE(435B)
----.github()
--------issue_template.md(132B)
----LICENSE(11KB)
----src()
--------test()
--------main()
----build.sbt(2KB)
----.gitignore(75B)
----project()
--------plugins.sbt(116B)
--------plugins()
--------build.properties(19B)
----README.md(7KB)