php memcache保存session的一个设置误区

本文介绍了PHP中使用Memcache和Memcached作为session保存处理器的区别。重点讲述了如何正确配置session.save_path参数,并强调了在使用Memcached时不应包含tcp协议前缀。

php中,使用memcache作为session的save handler 一般会使用如下设置:

php.ini里:

session.save_handler = memcache
session.save_path = “localhost:11211″

项目配置里:

ini_set(“session.save_handler”, “memcache”);
ini_set(“session.save_path”, “127.0.0.1:11211″);
在网上很多资料会写成这样:
session.save_path = “tcp://localhost:11211″
就是连接前缀里添加了tcp:// 这是会导致php的memcache模块写入失败,切记一定不要添加tcp协议前缀!

 
session.save_path string

Defines a comma separated of hostname:port entries to use for session server pool, for example “sess1:11211, sess2:11211″.

 
 
If you want to use ‘memcacheD’ extention not ‘memcache’ (there are two diffrent extentions) for session control,  you should pay attention to modify php.ini

Most web resource from google is based on memcache because It’s earlier version than memcacheD. They will say as following

session.save_handler = memcache
session.save_path = “tcp://localhost:11211″

But it’s not valid when it comes to memcacheD

you should modify php.ini like that

session.save_handler = memcached
session.save_path = “localhost:11211″

Look, there is no protocol indentifier

转载于:https://www.cnblogs.com/Jerry-blog/p/5044710.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值