downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

Memcache 関数> <
Last updated: Fri, 13 Nov 2009

view this page in

例1 memcache 拡張モジュールの概要

この例では、オブジェクトをキャッシュに保存した後に、改めて取得しなおします。 オブジェクトやその他の非スカラー型のデータは、保存される前に シリアライズされます。そのため (接続 ID などの) リソース型を 保存することはできません。

<?php

$memcache 
= new Memcache;
$memcache->connect('localhost'11211) or die ("接続できませんでした");

$version $memcache->getVersion();
echo 
"サーバのバージョン: ".$version."<br/>\n";

$tmp_object = new stdClass;
$tmp_object->str_attr 'test';
$tmp_object->int_attr 123;

$memcache->set('key'$tmp_objectfalse10) or die ("データをサーバに保存できませんでした");
echo 
"データをキャッシュに保存します (データの有効期限は 10 秒です)<br/>\n";

$get_result $memcache->get('key');
echo 
"キャッシュから取得したデータ:<br/>\n";

var_dump($get_result);

?>

例2 memcache セッションハンドラの使用例

<?php

$session_save_path 
"tcp://$host:$port?persistent=1&weight=2&timeout=2&retry_interval=10,  ,tcp://$host:$port  ";
ini_set('session.save_handler''memcache');
ini_set('session.save_path'$session_save_path);

?>



add a note add a note User Contributed Notes
memcache 拡張モジュールの概要
dkreuter at gmail dot com
01-Jun-2009 06:45
If the example doesn't work try to change "localhost" to "127.0.0.1".

Memcache 関数> <
Last updated: Fri, 13 Nov 2009
 
 
show source | credits | sitemap | contact | advertising | mirror sites