MemcontinuationedMemcached的Scala客户端
Memcontinuationed是Scala的异步memcached客户端。Memcontinuationed是JVM上最快的Memcached客户端,比spymemcached或 Whalin的客户端要快得多。
示例代码:
import com.dongxiguo.memcontinuationed.Memcontinuationed import com.dongxiguo.memcontinuationed.StorageAccessor import java.io._ import java.net._ import java.nio.channels.AsynchronousChannelGroup import java.util.concurrent.Executors import scala.util.continuations.reset import scala.util.control.Exception.Catcher object Sample { def main(args: Array[String]) { val threadPool = Executors.newCachedThreadPool() val channelGroup = AsynchronousChannelGroup.withThreadPool(threadPool) // The locator decide where the memcached server is. // You may want to implement ketama hashing here. def locator(accessor: StorageAccessor[_]) = { new InetSocketAddress("localhost", 1978) } val memcontinuationed = new Memcontinuationed(channelGroup, locator) // The error handler implicit def catcher:Catcher[Unit] = { case e: Exception => scala.Console.err.print(e) sys.exit(-1) } reset { memcontinuationed.set(MyKey("hello"), "Hello, World!") val result = memcontinuationed.require(MyKey("hello")) assert(result == "Hello, World!") println(result) sys.exit() } } } /** * `MyKey` specifies how to serialize the data of key/value pair. */ case class MyKey(override val key: String) extends StorageAccessor[String] { override def encode(output: OutputStream, data: String, flags: Int) { output.write(data.getBytes("UTF-8")) } override def decode(input: InputStream, flags: Int): String = { val result = new Array[Byte](input.available) input.read(result) new String(result, "UTF-8") } }
评论
rediscalaRedis的Scala客户端
rediscala是Redis的Scala非堵塞客户端开发包,支持异步I/O操作。示例代码:importredis.RedisClientimportscala.concurrent.Awaitimp
rediscalaRedis的Scala客户端
0
ScredisRedis 的 Scala 客户端
Scredis是一个Redis的Scala客户端开发包。基于Akka构建,特点是Reactive、非堵塞以及超级快。示例代码:import scredis._import scala.util.{ S
ScredisRedis 的 Scala 客户端
0
cassandra_client_scalaCassandra 的 Scala 客户端开发包
从名字上就可以看出,cassandra_client_scala 是 Cassandra 的 Sca
cassandra_client_scalaCassandra 的 Scala 客户端开发包
0
cassandra_client_scalaCassandra 的 Scala 客户端开发包
从名字上就可以看出,cassandra_client_scala是Cassandra的Scala编程语言的客户端开发包。
cassandra_client_scalaCassandra 的 Scala 客户端开发包
0