memcached 配置 config
- font size decrease font size increase font size
- Print Email
启动memcached
# service memcachedstart
启动memcached
# service memcachedstart
设置memcached自动启动
# chkconfig memcached on
memcached 配置文件
memcached 配置文件
#memcached 监听端口号
PORT="11211"
#memcached启动用户
USER="nobody"
# 最大并发链接数
MAXCONN="2048"
# memcached 启动后分配内存大小
CACHESIZE="4096"
# memcached启动的其它参数, memcached 监听的ip地址,只监听本机使用127.0.0.1
OPTIONS="-l 127.0.0.1"
安装php的memcached扩展包
# yum install php-pecl-memcache
使用下面测试例子测试
$memcache = new Memcache;
$memcache->connect('localhost', 11211) or die ("Could not connect");
$version = $memcache->getVersion();
echo "Server's version: ".$version."
\n";
$tmp_object = new stdClass;
$tmp_object->str_attr = 'test';
$tmp_object->int_attr = 123;
$memcache->set('key', $tmp_object, false, 10) or die ("Failed to save data at the server");
echo "Store data in the cache (data will expire in 10 seconds)
\n";
$get_result = $memcache->get('key');
echo "Data from the cache:
\n";
var_dump($get_result);
?>
Notice: Only variables should be assigned by reference in /var/www/vhosts/shan.info/httpdocs/templates/gk_publisher/html/com_k2/templates/default/item.php on line 478
back to top