Сер 172012
 

Установка Memcached под FreeBSD

cd /usr/ports/databases/memcached

make install clean
ee /etc/rc.conf

Добавляем строку:

memcached_enable="YES"
/usr/local/etc/rc.d/memcached start

Проверяем: netstat -an | grep 11211
Ставим расширение для php:

cd /usr/ports/databases/pecl-memcache

make install clean
/usr/local/bin/php -i | grep -i 'memcache'

apachectl restart

<?php
$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);
?>

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(required)

(required)