本文整理汇总了PHP中Memcached::create方法的典型用法代码示例。如果您正苦于以下问题:PHP Memcached::create方法的具体用法?PHP Memcached::create怎么用?PHP Memcached::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Memcached
的用法示例。
在下文中一共展示了Memcached::create方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testWithTimeout
public function testWithTimeout()
{
$cache = Memcached::create('localhost')->setTimeout(200);
$cache->add('a', 'b');
$this->assertEquals($cache->get('a'), 'b');
$cache->clean();
}
示例2: dirname
<?php
// $Id$
require dirname(__FILE__) . '/../../global.inc.php.tpl';
// set up default cache peer
Cache::setPeer(Memcached::create());
// or even several aggregated peers
Cache::setPeer(AggregateCache::create()->addPeer('memcached daemon at localhost', Memcached::create())->addPeer('local low-priority file system', RubberFileSystem::create('/tmp/onphp-cache'), AggregateCache::LEVEL_VERYLOW));
// let's test out cache system
$ts = new Timestamp(time());
$key = 'timestamp_object';
if (Cache::me()->set($key, $ts, 2)) {
echo "object is in cache now\n";
if ($cached = Cache::me()->get($key)) {
echo "got from cache:\n";
print_r($cached);
}
} else {
echo "failed to store object in cache\n";
}
示例3: testCyclicAggregateCache
public function testCyclicAggregateCache()
{
$this->doTestMemcached(CyclicAggregateCache::create()->setSummaryWeight(42)->addPeer('first', Memcached::create(), 25)->addPeer('second', PeclMemcached::create(), 1)->addPeer('third', PeclMemcached::create(), 13));
}