欢迎来到天天文库
浏览记录
ID:9801193
大小:162.50 KB
页数:14页
时间:2018-05-10
《memcached 协议中英文对照》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、Memcached协议中英文对照协议Protocolmemcached的客户端使用TCP链接与服务器通讯。(UDP接口也同样有效,参考后文的“UDP协议”)一个运行中的memcached服务器监视一些(可设置)端口。客户端连接这些端口,发送命令到服务器,读取回应,最后关闭连接。ClientsofmemcachedcommunicatewithserverthroughTCPconnections.(AUDPinterfaceisalsoavailable;detailsarebelowunder"U
2、DPprotocol.")Agivenrunningmemcachedserverlistensonsome(configurable)port;clientsconnecttothatport,sendcommandstotheserver,readresponses,andeventuallyclosetheconnection.结束会话不需要发送任何命令。当不再需memcached服务时,要客户端可以在任何时候关闭连接。需要注意的是,鼓励客户端缓存这些连接,而不是每次需要存取数据时都重新打开连
3、接。这是因为memcached被特意设计成及时开启很多连接也能够高效的工作(数百个,上千个如果需要的话)。缓存这些连接,可以消除建立连接所带来的开销(/*/相对而言,在服务器端建立一个新连接的准备工作所带来的开销,可以忽略不计。)。Thereisnoneedtosendanycommandtoendthesession.Aclientmayjustclosetheconnectionatanymomentitnolongerneedsit.Note,however,thatclientsareenc
4、ouragedtocachetheirconnectionsratherthanreopenthemeverytimetheyneedtostoreorretrievedata.Thisisbecausememcachedisespeciallydesignedtoworkveryefficientlywithaverylargenumber(manyhundreds,morethanathousandifnecessary)ofopenconnections.Cachingconnectionsw
5、illeliminatetheoverheadassociatedwithestablishingaTCPconnection(theoverheadofpreparingforanewconnectionontheserversideisinsignificantcomparedtothis).在memcache协议中发送的数据分两种:文本行和自由数据。文本行被用于来自客户端的命令和服务器的回应。自由数据用于客户端从服务器端存取数据时。同样服务器会以字节流的方式传回自由数据。/*/服务器不用关心自
6、由数据的字节顺序。自由数据的特征没有任何限制;但是通过前文提到的文本行,这项数据的接受者(服务器或客户端),便能够精确地获知所发送的数据库的长度。Therearetwokindsofdatasentinthememcacheprotocol:textlinesandunstructureddata.Textlinesareusedforcommandsfromclientsandresponsesfromservers.Unstructureddataissentwhenaclientwantsto
7、storeorretrievedata.Theserverwilltransmitbackunstructureddatainexactlythesamewayitreceivedit,asabytestream.Theserverdoesn'tcareaboutbyteorderissuesinunstructureddataandisn'tawareofthem.Therearenolimitationsoncharactersthatmayappearinunstructureddata;ho
8、wever,thereaderofsuchdata(eitheraclientoraserver)willalwaysknow,fromaprecedingtextline,theexactlengthofthedatablockbeingtransmitted.文本行固定以“r”(回车符紧跟一个换行符)结束。自由数据也是同样会以“r”结束,但是r(回车符)、(换行符),以及任何其他8位字符,均可出现在数据中。因此,当客户端从服务器取回数据时,必须使
此文档下载收益归作者所有