Memcontinuationed Memcached的Scala客户端开源项目

我要开发同款
匿名用户2013年02月03日
93阅读

技术信息

开源地址
https://github.com/Atry/memcontinuationed
授权协议
Apache

作品详情

Memcotiuatioed是Scala的异步memcached客户端。Memcotiuatioed是JVM上最快的Memcached客户端,比spymemcached或 Whali的客户端要快得多。

示例代码:

importcom.dogxiguo.memcotiuatioed.Memcotiuatioedimportcom.dogxiguo.memcotiuatioed.StorageAccessorimportjava.io._importjava.et._importjava.io.chaels.AsychroousChaelGroupimportjava.util.cocurret.Executorsimportscala.util.cotiuatios.resetimportscala.util.cotrol.Exceptio.CatcherobjectSample{ defmai(args:Array[Strig]){  valthreadPool=Executors.ewCachedThreadPool()  valchaelGroup=AsychroousChaelGroup.withThreadPool(threadPool)  //Thelocatordecidewherethememcachedserveris.  //Youmaywattoimplemetketamahashighere.  deflocator(accessor:StorageAccessor[_])={   ewIetSocketAddress("localhost",1978)  }  valmemcotiuatioed=ewMemcotiuatioed(chaelGroup,locator)  //Theerrorhadler  implicitdefcatcher:Catcher[Uit]={   casee:Exceptio=>    scala.Cosole.err.prit(e)    sys.exit(-1)  }  reset{   memcotiuatioed.set(MyKey("hello"),"Hello,World!")   valresult=memcotiuatioed.require(MyKey("hello"))   assert(result=="Hello,World!")   pritl(result)   sys.exit()  } }}/** *`MyKey`specifieshowtoserializethedataofkey/valuepair. */caseclassMyKey(overridevalkey:Strig)extedsStorageAccessor[Strig]{ overridedefecode(output:OutputStream,data:Strig,flags:It){  output.write(data.getBytes("UTF-8")) } overridedefdecode(iput:IputStream,flags:It):Strig={  valresult=ewArray[Byte](iput.available)  iput.read(result)  ewStrig(result,"UTF-8") }}

 

功能介绍

Memcontinuationed是Scala的异步memcached客户端。Memcontinuationed是JVM上最快的Memcached客户端,比spymemcached或 Whali...

声明:本文仅代表作者观点,不代表本站立场。如果侵犯到您的合法权益,请联系我们删除侵权资源!如果遇到资源链接失效,请您通过评论或工单的方式通知管理员。未经允许,不得转载,本站所有资源文章禁止商业使用运营!
下载安装【程序员客栈】APP
实时对接需求、及时收发消息、丰富的开放项目需求、随时随地查看项目状态

评论