当前位置: 首页 > news >正文

塔城地区网站建设_网站建设公司_产品经理_seo优化

有做淘宝网站的,我想看女生尿频怎么办,wordpress 增加侧边栏,邯郸建设企业网站1 命令行查看状态 很多时候我们需要去查看Memcached 的使用状态#xff0c;比如Memcached 的运行时间#xff0c;使用状态等等。在Windows系统中我们可以使用telnet 命令来查看Memcached 的相关运行情况。 开始—运行cmd 运行得到如下#xff1a; 输入telnet命令#x… 1 命令行查看状态   很多时候我们需要去查看Memcached 的使用状态比如Memcached 的运行时间使用状态等等。在Windows系统中我们可以使用telnet 命令来查看Memcached 的相关运行情况。   开始—运行àcmd 运行得到如下   输入telnet命令 telnet 服务地址 端口    Memcached 的默认端口号是11211      输入stats 命令 在这里屏幕是空白看不到输入的内容回车之后可以看到Memcached的运行相关信息。    Pid: Memcached 服务器中的进程编号    UptimeMemcached服务器启动之后所经历的时间单位秒    Time 当前系统时间单位秒   Version: Memcached 的版本号   pointer_size服务器所在主机操作系统的指针大小一般为32或64   curr_items表示当前缓存中存放的所有缓存对象的数量   total_items表示从memcached服务启动到当前时间系统存储过的所有对象的数量包括已经删除的对象   bytes表示系统存储缓存对象所使用的存储空间单位为字节   curr_connections表示当前系统打开的连接数   total_connections表示从memcached服务启动到当前时间系统打开过的连接的总数   cmd_get 查询缓存的次数即使不成功也算一次   cmd_set 保存数据的次数当然这里只保存成功的次数   get_hits表示获取数据成功的次数。   get_misses表示获取数据失败的次数。   evictions为了给新的数据项目释放空间从缓存移除的缓存对象的数目。比如超过缓存大小时根据LRU算法移除的对象以及过期的对象   bytes_readmemcached服务器从网络读取的总的字节数   bytes_writtenmemcached服务器发送到网络的总的字节数   limit_maxbytesmemcached服务缓存允许使用的最大字节数   threads被请求的工作线程的总数量缓存命中率 get_hits / cmd_get * 100% ;  2 Memcached 存储机制        关于Memcached的存储机制在网上搜了一下讲解基本上都是千篇一律的。 memcached默认情况下采用了名为Slab Allocator的机制分配、管理内存。在之前的版本中Memcached存储会导致很多内存碎片从而加重了操作系统对内存管理的负担。Slab Allocator的基本原理是按照预先规定的大小将分配的内存分割成特定长度的块 以完全解决内存碎片问题。借用一张图说明一下        Slab Allocation 将分配的内存分割成各种尺寸的chunk (块)并把大小相同尺寸的chunk分为一组就如上图一样分割了 88b,112b,144b等尺寸。其实Slab Allocation还有重复利用内存的功能也就是说分配的内存不会释放而是重复利用。 当存储数据的时候它会自动去查找最为匹配的chunk然后将数据存储到其中。比如我存储数据的大小为110B,那么它会存储到112B的chunk中。      上面的问题来了我存储只需要110B但是我存储到112B的chunk中。如下图(借用)        那么在110b的存储中会浪费2B的内存空间至于如何完全解决这个内存空间浪费的问题还没有很好的方案不过Memcached的 增长因子(Growth Factor)能够适当解决此问题。目前Memcached的默认增长因子      是1.25也就是说会以原有的最大值基础上乘以1.25 来分配空间。  3 Memcached 对内存资源的有效利用 之前已经提到过了Memcached 会重复利用已经分配的内存也就是说不会去删除已有的数据而且释放内存空间而是数据过期之后用户将数据不可见。          Memcached 还是用了一种Lazy Expiration (延迟过期[姑且这样翻译]) 技术就是Memcached不会去监视服务器上的数据是否过期而是等待get的时候检查时间戳是否过期减少Memcached在监控数据上所用到的时间。Memcached 不会去释放已经使用的内存空间但是如果分配的内存空间已经满了而Memcached 是如何去保证内存空间的重复使用呢Memcached 是用了 Least Recently UsedLRU 机制来协调内存空间的使用。LRU 意思就是最少最近使用当此处内存空间数据最长时间没有使用而且使用次数很少在存储新的数据的同时就会覆盖此处空间。  4 Memcached 客户端使用简单封装 本文很多都是理论上的分析这些大多也是从网络上看来的根据自己的理解和实际的应用做了一些总结。有时候我们使用Memcached的客户端时并不是那么的友好这里对其做了一下简单的封装抽象出来了一个接口 1 usingSystem;2 usingSystem.Collections.Generic;3 usingSystem.Linq;4 usingSystem.Text;5 usingSystem.Collections;6 7 namespaceMemcachedTest8 {9 publicinterfaceICache10 {11 boolContainKey(stringargKey);12 13 boolAdd(stringargKey,objectargValue);14 15 boolAdd(stringargKey, objectargValue, DateTime argDateExpiration);16 17 boolAddT(stringargKey, T entity) whereT : class;18 19 boolAddT(stringargKey, T entity, DateTime argDateExpiration) whereT : class;20 21 boolSet(stringargKey, objectargValue);22 23 boolSet(stringargKey, objectargValue, DateTime argDateExpiration);24 25 boolSetT(stringargKey, T entity) whereT : class;26 27 boolSetT(stringargKey, T entity, DateTime argDateExpiration) whereT : class;28 29 boolReplace(stringargKey,objectargValue);30 31 boolReplace(stringargKey,objectargValue,DateTime argDateExpiration);32 33 boolReplaceT(stringargKey, T entity) whereT : class;34 35 boolReplaceT(stringargKey, T entity, DateTime argDateExpiration) whereT : class;36 37 objectGet(stringargKey);38 39 T GetT(stringargKey);40 41 boolRemove(stringargKey);42 43 boolRemove(stringargKey, DateTime argDateExpiration);44 45 boolRemove();46 47 boolRemove(ArrayList servers);48 49 } 50 }  下面这段代码对上面的接口进行了实现里面的代码大多数人应该能够看懂是比较简单的代码封装如果能够了解本人上一篇的简单应用对于这个封装的理解应该没有难度。实现代码如下 1 usingSystem;2 usingSystem.Collections.Generic;3 usingSystem.Linq;4 usingSystem.Text;5 usingMemcached.ClientLibrary;6 usingSystem.Collections;7 8 namespaceMemcachedTest9 {10 publicclassMemcache:ICache11 {12 privateMemcachedClient client;13 privatestaticMemcache memcache;14 15 ///summary16 ///构造方法17 ////summary18 protectedMemcache()19 {20 SockIOPool pool SockIOPool.GetInstance();21 string[] servers { 127.0.0.1:11211};22 pool.SetServers(servers);23 pool.MinConnections 3;24 pool.MaxConnections 5;25 pool.InitConnections 3;26 pool.SocketConnectTimeout 5000;27 pool.Initialize();28 this.client newMemcachedClient();29 client.EnableCompression false;30 }31 32 publicstaticMemcache Instance()33 {34 if(memcache null)35 {36 memcache newMemcache();37 }38 returnmemcache;39 }40 41 42 ///summary43 ///判断是否包含某个键44 ////summary45 ///param nameargKey键值/param46 ///returns/returns47 publicboolContainKey(stringargKey)48 {49 returnclient.KeyExists(argKey);50 }51 52 ///summary53 ///添加缓存数据54 ////summary55 ///param nameargKey键值/param56 ///param nameargValue存储值/param57 ///returns/returns58 publicboolAdd(stringargKey, objectargValue)59 {60 returnclient.Add(argKey,argValue);61 }62 63 ///summary64 ///添加缓存数据65 ////summary66 ///param nameargKey键值/param67 ///param nameargValue存储值/param68 ///param nameargDateExpiration过期时间/param69 ///returns/returns70 publicboolAdd(stringargKey, objectargValue, DateTime argDateExpiration)71 {72 returnclient.Add(argKey, argValue, argDateExpiration);73 }74 75 ///summary76 ///添加缓存数据77 ////summary78 ///typeparam nameT存储对象类型/typeparam79 ///param nameargKey键值/param80 ///param nameentity存储值/param81 ///returns/returns82 publicboolAddT(stringargKey, T entity) whereT : class83 {84 returnclient.Add(argKey, entity);85 }86 87 ///summary88 ///添加缓存数据89 ////summary90 ///typeparam nameT存储对象类型/typeparam91 ///param nameargKey键值/param92 ///param nameentity存储值/param93 ///param nameargDateExpiration过期时间/param94 ///returns/returns95 publicboolAddT(stringargKey, T entity, DateTime argDateExpiration) whereT : class96 {97 returnclient.Add(argKey, entity, argDateExpiration);98 }99 100 ///summary101 ///添加缓存数据如果存在则替换原有数据102 ////summary103 ///param nameargKey键值/param104 ///param nameargValue存储值/param105 ///returns/returns106 publicboolSet(stringargKey, objectargValue)107 {108 if(ContainKey(argKey))109 {110 returnfalse;111 }112 returnclient.Set(argKey, argValue);113 }114 115 ///summary116 ///添加缓存数据如果存在则替换原有数据117 ////summary118 ///param nameargKey键值/param119 ///param nameargValue存储值/param120 ///param nameargDateExpiration过期时间/param121 ///returns/returns122 publicboolSet(stringargKey, objectargValue, DateTime argDateExpiration)123 {124 if(ContainKey(argKey))125 {126 returnfalse;127 }128 returnclient.Set(argKey, argValue, argDateExpiration);129 }130 131 ///summary132 ///添加缓存数据如果存在则替换原有数据133 ////summary134 ///typeparam nameT存储对象类型/typeparam135 ///param nameargKey键值/param136 ///param nameentity存储值/param137 ///returns/returns138 publicboolSetT(stringargKey, T entity) whereT : class139 {140 if(ContainKey(argKey))141 {142 returnfalse;143 }144 returnclient.Set(argKey, entity);145 }146 147 ///summary148 ///添加缓存数据如果存在则替换原有数据149 ////summary150 ///typeparam nameT存储对象类型/typeparam151 ///param nameargKey键值/param152 ///param nameentity存储值/param153 ///param nameargDateExpiration过期时间/param154 ///returns/returns155 publicboolSetT(stringargKey, T entity, DateTime argDateExpiration) whereT : class156 {157 if(ContainKey(argKey))158 {159 returnfalse;160 }161 returnclient.Set(argKey, entity, argDateExpiration);162 }163 164 165 ///summary166 ///替换原有缓存167 ////summary168 ///param nameargKey键值/param169 ///param nameargValue存储值/param170 ///returns/returns171 publicboolReplace(stringargKey, objectargValue)172 {173 returnclient.Replace(argKey,argValue);174 }175 176 ///summary177 ///替换原有缓存178 ////summary179 ///param nameargKey键值/param180 ///param nameargValue存储值/param181 ///param nameargDateExpiration过期时间/param182 ///returns/returns183 publicboolReplace(stringargKey, objectargValue, DateTime argDateExpiration)184 {185 returnclient.Replace(argKey,argValue,argDateExpiration);186 }187 188 publicboolReplaceT(stringargKey, T entity) whereT : class189 {190 returnclient.Replace(argKey,entity);191 }192 193 publicboolReplaceT(stringargKey, T entity, DateTime argDateExpiration) whereT : class194 {195 returnclient.Replace(argKey, entity,argDateExpiration);196 }197 198 publicobjectGet(stringargKey)199 {200 returnclient.Get(argKey);201 }202 203 publicT GetT(stringargKey)204 {205 T entitydefault(T);206 entity (T)client.Get(argKey);207 returnentity;208 }209 210 publicboolRemove(stringargKey)211 {212 returnclient.Delete(argKey);213 }214 215 publicboolRemove(stringargKey, DateTime argDateExpiration)216 {217 returnclient.Delete(argKey,argDateExpiration);218 }219 220 publicboolRemove()221 {222 returnclient.FlushAll();223 }224 225 publicboolRemove(ArrayList servers)226 {227 returnclient.FlushAll(servers);228 }229 } 230 }  上面的代码没有注释因为提交不了这么长的代码去掉了注释。代码大家可以看懂的这里不做过多的讲解。    学习例子源码下载 转载于:https://www.cnblogs.com/aaa6818162/archive/2011/04/20/2022305.html
http://www.ihoyoo.com/news/38648.html

相关文章:

  • 加强网站建设的措施网站建设常用的工具
  • 如何打破违法网站wordpress中添加登陆页面
  • 广东省网站备案注销成都网站建设优化企业排名
  • 做外贸雨伞到什么网站销售管理系统哪家好
  • 电子商务网站建设的首要问题产品设计属于什么大类
  • cp网站开发搭建网站多少钱一套wordpress 微信采集器
  • 淮安网站建设方案世界优秀摄影作品网站
  • 网站建设选哪个公司wordpress迁移后后台页面打不开
  • 米托网站建设苏州建站方法
  • 好搜360网站网页制作工具大全
  • 网站建设企业合作邀请函咖啡网站建设设计规划书
  • 专业彩票网站开发 APP开发郑州做网站推广的公司哪家好
  • 网站策划书市场分析2021年最新军事新闻
  • 设计房子装修效果图软件韶山百度seo
  • 北京网站建设公司案例seo快速排名点击
  • 郑州那家做网站便宜网站建设手机银行修改登录密码
  • 做管理信息的网站建设工程材料信息价查什么网站
  • wordpress模版做网站上海最好的网吧
  • 青岛人力资源招聘官网网站建设及优化 赣icp
  • 杭州网站建设公司代理加盟dw做的网站怎么
  • 苏州网站建设一站通wordpress author id
  • 公司网站建设费用怎么记账济南网站搜索优化
  • 旅游网站建设初衷工厂拿货回家加工
  • 巴中网站开发wordpress导航图片尺寸
  • 临海受欢迎营销型网站建设网站建设提供商
  • 宁夏住房和城乡建设厅网站广东500强企业名单一览表
  • 企业网站建设推广合同企业官网首页图片
  • 青岛网站设计选哪家android开发工具排行榜
  • 北京网站seo设计wordpress不能选择数据库
  • c2c平台怎么下载seo技术外包公司