How to install memcache using session in windows + xampp + php5.4

Source: Internet
Author: User
Environment: windowsxamppphp5.41. add php_memcache.dll2 to the php installation directory phpext. Modify php. ini and add extensionphp_memcache.dll to php. ini and set [Memcache] memcache. Memory.

Environment: windowsxamppphp5.4 1. add php_memcache.dll 2 to the php installation Directory php \ ext. modify php. ini in php. extension = php_memcache.dll is added to ini and [Memcache] memcache is set. allow_failover = 1 memcache. max_failover_attempts = 20 memcache. chunk_size = 8192 m

Environment: windows + xampp + php5.4

1. Add php_memcache.dll to the php installation Directory php \ ext.

2. Modify php. ini

Add extension = php_memcache.dll in php. ini.
And set
[Memcache]
Memcache. allow_failover = 1
Memcache. max_failover_attempts = 20
Memcache. chunk_size = 8192
Memcache. default_port = 11211

Modify session. save_handler = files to session. save_handler = memcache

3. Restart apache

4. In the D: \ memcacheddirectory, copy the file memcached.exe;

When enabling sessions under memcache, you must enable memcache.

5. Enable memcache

(1) cmd mode: Access C: \ Windows \ system32right to cmd.exe, run as Administrator

Enter the D: \ memcacheddirectory in cmd, and enter (1)memcached.exe-d install;(2)memcached.exe-d start

(2) manually enable the memcache Service

6. Use memcache In the CI framework:

Add code to index. php In the root directory file

Ini_set ("session. save_handler", "memcache ");
Ini_set ("session. save_path", '2017. 0.0.1: 661 ');
Session_set_cookie_params (3600*24*30, '/', '. domain. xom ');
Session_start ();

Initialize memcache and enable the session. In this way, you do not need to initialize or enable the session repeatedly in other CI control files;

Session_set_cookie_params (3600*24*30, '/', '. domain. xom'); used to set the session's work domain and solve the session cross-domain problem,

Domain is a level-1 domain name.

5. test:

 connect('127.0.0.1',11211) or die('shit');                 $memcache->set('key','hello memcache!');                 $out = $memcache->get('key');                 echo $out;              }}?>
 

If "hello memcache!" Is output successfully !", It indicates that memcache has been configured successfully.


Link: http://codeigniter.org.cn/user_guide/libraries/sessions.html

Http://www.yaolei.info/archives/194

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.