本文整理汇总了PHP中Memcached::fetchAll方法的典型用法代码示例。如果您正苦于以下问题:PHP Memcached::fetchAll方法的具体用法?PHP Memcached::fetchAll怎么用?PHP Memcached::fetchAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Memcached
的用法示例。
在下文中一共展示了Memcached::fetchAll方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fetchAll
/**
* FetchAll
*
* @throws Exception
* @return array
*/
public function fetchAll()
{
$result = $this->memcached->fetchAll();
if ($result === false) {
throw new Exception\RuntimeException("Memcached::fetchAll() failed");
}
$select = $this->stmtOptions['select'];
foreach ($result as &$elem) {
if (!in_array('key', $select)) {
unset($elem['key']);
}
}
return $result;
}
示例2: setUp
public function setUp()
{
if (!class_exists('\\Memcached', true)) {
$this->markTestSkipped('Memcached is not installed');
}
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
// setup the default timeout (avoid max execution time)
socket_set_option($socket, SOL_SOCKET, SO_SNDTIMEO, array('sec' => 1, 'usec' => 0));
$result = @socket_connect($socket, '127.0.0.1', 11211);
if (!$result) {
$this->markTestSkipped('Memcached is not running');
}
socket_close($socket);
$memcached = new \Memcached();
$memcached->addServer('127.0.0.1', 11211);
$memcached->fetchAll();
}
示例3: fetchAll
/**
* FetchAll
*
* @throws Exception
* @return array
*/
public function fetchAll()
{
$prefixL = strlen($this->stmtOptions['namespace'] . $this->getOptions()->getNamespaceSeparator());
$result = $this->memcached->fetchAll();
if ($result === false) {
throw new Exception\RuntimeException("Memcached::fetchAll() failed");
}
$select = $this->stmtOptions['select'];
foreach ($result as &$elem) {
if (in_array('key', $select)) {
$elem['key'] = substr($elem['key'], $prefixL);
} else {
unset($elem['key']);
}
}
return $result;
}
示例4: forget
/**
* Remove an item from the cache.
*
* @param string $key
* @return bool
*/
public function forget($key)
{
if ($key == '*') {
$this->flush();
return true;
}
$pattern = str_replace(['\\*', '*'], '.+', preg_quote($this->getPrefixWithLocale(true) . $key));
$check = true;
$all = $this->memcached->fetchAll();
if ($all) {
$check = false;
foreach ($all as $cache) {
if (preg_match('~^' . $pattern . '$~i', $cache['key'])) {
if (!$this->memcached->delete($cache['key'])) {
$check = false;
}
}
}
}
return $check;
}
示例5: testFetchAllEmptyResults
public function testFetchAllEmptyResults()
{
$memcached = new Memcached();
$this->assertFalse($memcached->fetchAll());
}
示例6: Memcached
<?php
session_start();
$m = new Memcached();
$m->addServer('localhost', 11211);
$m->set('key', 'value', time() + 30);
$m->delete('key1');
$m->fetchAll();
// var_dump($m);
$memcache = new Memcache();
$memcache->connect('localhost', 11211) or die("Could not connect");
$version = $memcache->getVersion();
echo "Server's version: " . $version . "<br/>\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)<br/>\n";
$get_result = $memcache->get('key');
echo "Data from the cache:<br/>\n";
var_dump($get_result);
示例7: fetchAll
/**
* Fetch all remaining results from the last request.
*
* @link http://www.php.net/manual/en/memcached.fetchall.php
*
* @return array|bool Returns the results or FALSE on failure.
*/
public function fetchAll()
{
return $this->m->fetchAll();
}
示例8: getAll
/**
* @inheritdoc
*/
public function getAll()
{
return $this->storage->fetchAll();
}
示例9: fetchAll
/**
* Fetch all remaining results from the last request.
*
* @link http://www.php.net/manual/en/memcached.fetchall.php
*
* @return array|bool Returns the results or FALSE on failure.
*/
public function fetchAll()
{
return $this->daemon->fetchAll();
}