memcached 配置 config

启动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);

?>

Last modified onSunday, 14 October 2012 04:07

( ! ) Warning: count(): Parameter must be an array or an object that implements Countable in /var/www/vhosts/shan.info/httpdocs/templates/gk_publisher/html/com_k2/templates/default/item.php on line 169
Call Stack
#TimeMemoryFunctionLocation
10.0020412184{main}( ).../index.php:0
20.08854262136Joomla\CMS\Application\SiteApplication->execute( ).../index.php:49
30.08854262136Joomla\CMS\Application\SiteApplication->doExecute( ).../CMSApplication.php:196
40.452611452984Joomla\CMS\Application\SiteApplication->dispatch( ).../SiteApplication.php:233
50.453611477296Joomla\CMS\Component\ComponentHelper::renderComponent( ).../SiteApplication.php:194
60.454611532624Joomla\CMS\Component\ComponentHelper::executeComponent( ).../ComponentHelper.php:377
70.455011560024require_once( '/var/www/vhosts/shan.info/httpdocs/components/com_k2/k2.php' ).../ComponentHelper.php:402
80.466211959656K2ControllerItem->execute( ).../k2.php:64
90.466211959656K2ControllerItem->display( ).../BaseController.php:710
100.476812610360K2ControllerItem->display( ).../item.php:78
110.476812610360K2ControllerItem->display( ).../controller.php:19
120.481012981400Joomla\CMS\Cache\Controller\ViewController->get( ).../BaseController.php:663
130.482613001768K2ViewItem->display( ).../ViewController.php:102
140.547015778536K2ViewItem->display( ).../view.html.php:742
150.547015778536K2ViewItem->loadTemplate( ).../HtmlView.php:230
160.548815951472include( '/var/www/vhosts/shan.info/httpdocs/templates/gk_publisher/html/com_k2/templates/default/item.php' ).../HtmlView.php:701

( ! ) 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
Call Stack
#TimeMemoryFunctionLocation
10.0020412184{main}( ).../index.php:0
20.08854262136Joomla\CMS\Application\SiteApplication->execute( ).../index.php:49
30.08854262136Joomla\CMS\Application\SiteApplication->doExecute( ).../CMSApplication.php:196
40.452611452984Joomla\CMS\Application\SiteApplication->dispatch( ).../SiteApplication.php:233
50.453611477296Joomla\CMS\Component\ComponentHelper::renderComponent( ).../SiteApplication.php:194
60.454611532624Joomla\CMS\Component\ComponentHelper::executeComponent( ).../ComponentHelper.php:377
70.455011560024require_once( '/var/www/vhosts/shan.info/httpdocs/components/com_k2/k2.php' ).../ComponentHelper.php:402
80.466211959656K2ControllerItem->execute( ).../k2.php:64
90.466211959656K2ControllerItem->display( ).../BaseController.php:710
100.476812610360K2ControllerItem->display( ).../item.php:78
110.476812610360K2ControllerItem->display( ).../controller.php:19
120.481012981400Joomla\CMS\Cache\Controller\ViewController->get( ).../BaseController.php:663
130.482613001768K2ViewItem->display( ).../ViewController.php:102
140.547015778536K2ViewItem->display( ).../view.html.php:742
150.547015778536K2ViewItem->loadTemplate( ).../HtmlView.php:230
160.548815951472include( '/var/www/vhosts/shan.info/httpdocs/templates/gk_publisher/html/com_k2/templates/default/item.php' ).../HtmlView.php:701
back to top