设为首页 收藏本站
查看: 994|回复: 0

[经验分享] 在Win开发环境下面配置了一下Memcached

[复制链接]
累计签到:1 天
连续签到:1 天
发表于 2015-9-1 09:13:59 | 显示全部楼层 |阅读模式
开发环境win下面配置使用Memcached方法概述   再简单的事情没有做一遍都不能明白其中时候如此,今天配置Memcached就发现这个问题。帮助很全,先是在memcached for Windows获取到了需要的win下面的Memcached,按照方法:
  引用
  Unzip the binaries in your desired directory (eg. c:memcached)
Install the service using the command: 'c:memcachedmemcached.exe -d install' from the command line
Start the server from the Microsoft Management Console or by running the following command: 'c:memcachedmemcached.exe -d start'
Use the server, by default listening to port 11211

  然后
  在php.ini 加入一行 'extension=php_memcache.dll'
  然后到 http://pecl4win.php.net/ext.php/php_memcache.dll获取php_memcache.dll
  并复制到 ext 中(记住版本不要错了!)
  重启Apache,发现PHPInfo就是提示出不来memcache,真是无语了,代码测试总是提示
  引用
  Fatal error: Class 'Memcache' not found in D:xampplitehtdocsmemcacheindex.php on line 20
  开始觉得奇怪,于是搜索在官方网站发现了http://www.php.net/manual/zh/ref.memcache.php

  
  Hi there:
For run memcached in a windows box: (tested with latest php,apache and memcache in xp sp2)
a) download the php_memcache.dll it can be found in the pecl file.
b) put the dll in the extension folder (c:/php/extension for example). You cannot miss this folder because they are filled with php*.dll files. In some cases the extension folder used is the system32, a non-standard way to put dll but still works.
c)configure the php.ini
; i put this like the latest extension
extension=php_memcache.dll
; i'm not sure about this but don't hurts..
[Memcache]
memcache.allow_failover = 1
memcache.max_failover_attempts=20
memcache.chunk_size =8192
memcache.default_port = 11211
d)This is important, memcached works with a EXTERNAL service. This service must be downloaded and installed prior to use the memcache. I use: http://jehiah.cz/projects/memcached-win32/
e)Remember to install the service and to start the service memcached.exe -d install for install and run services.msc for start the memcached service (or restart the system).
f) check the firewall ports.
Finally restart the apache/iis and runs some test. At least in phpinfo must show some info about the memcache.
Final notes :The "awe" about memcache is not only can help for speed some process (or reduce the cpu use), also can be used like a global session for store a whole object also this "global session" is shared among all the users, like APPLICATION used in ASP. So (for example) it's possible to do a user counter without needing of database or writing a file.

 试试态度加上看了一下,看到了熟悉的东西了:  view plaincopy to clipboardprint?
  $mem=newMemcache;  
  $mem->connect('127.0.0.1',11211);  
   
  $mem->set('key','Thisisatest!',0,60);  
   
  $val=$mem->get('key');  
  echo$val; 
  $mem = new Memcache;
$mem->connect('127.0.0.1', 11211);
$mem->set('key', 'This is a test!', 0, 60);
$val = $mem->get('key');
echo $val;
  在浏览器输出了
  This is a test!
    另外作为服务器开发者,自然很关注的一个问题就是这个Memcached的原理问题,在老农如是想,如是说,如是为博客中提到:
  引用
  Memcached 本身的启动过程,在 memcached.c 的 main 函数中顺序如下:
  1 、调用 settings_init() 设定初始化参数
  2 、从启动命令中读取参数来设置 setting 值
  3 、设定 LIMIT 参数
  4 、开始网络 socket 监听(如果非 socketpath 存在)( 1.2 之后支持 UDP 方式)
  5 、检查用户身份( Memcached 不允许 root 身份启动)
  6 、如果有 socketpath 存在,开启 UNIX 本地连接(Sock 管道)
  7 、如果以 -d 方式启动,创建守护进程(如上调用 daemon 函数)
  8 、初始化 item 、 event 、状态信息、 hash 、连接、 slab
  9 、如设置中 managed 生效,创建 bucket 数组
  10 、检查是否需要锁定内存页
    11 、初始化信号、连接、删除队列
  
  12 、如果 daemon 方式,处理进程 ID
  13 、event 开始,启动过程结束, main 函数进入循环。

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-108168-1-1.html 上篇帖子: Memcached Telnet Interface 下篇帖子: Memcached 使用 及.NET客户端调用
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表