本文整理匯總了PHP中Memcached::isPristine方法的典型用法代碼示例。如果您正苦於以下問題:PHP Memcached::isPristine方法的具體用法?PHP Memcached::isPristine怎麽用?PHP Memcached::isPristine使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Memcached
的用法示例。
在下文中一共展示了Memcached::isPristine方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: Memcached
<?php
error_reporting(E_ALL & ~E_NOTICE);
require_once 'config.php';
$cache = new Memcached();
if ($cache->isPristine()) {
$cache->addServer("localhost", 11211);
}
if ($_GET['action'] == 'list') {
$page = $_GET['page'];
if (!($data = $cache->get("page_" . $page)) && $cache->getResultCode() == Memcached::RES_NOTFOUND) {
$ch = curl_init("http://test.hiskenya.org/api/users.json?page={$page}");
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERNAME, USERNAME);
curl_setopt($ch, CURLOPT_PASSWORD, PASSWORD);
$data = curl_exec($ch);
$cache->add("page_" . $page, $data);
curl_close($ch);
}
echo $data;
} else {
if ($_GET['action'] == 'info') {
$id = $_GET['id'];
if (!($data = $cache->get("user_" . $id)) && $cache->getResultCode() == Memcached::RES_NOTFOUND) {
$url = $_GET['url'];
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERNAME, USERNAME);
curl_setopt($ch, CURLOPT_PASSWORD, PASSWORD);
示例2: Memcached
<?php
$m1 = new Memcached('id1');
$m1->setOption(Memcached::OPT_PREFIX_KEY, "foo_");
var_dump($m1->isPristine());
$m1 = new Memcached('id1');
var_dump($m1->isPristine());
$m2 = new Memcached('id1');
var_dump($m2->isPristine());
// this change affects $m1
$m2->setOption(Memcached::OPT_PREFIX_KEY, "bar_");
$m3 = new Memcached('id2');
var_dump($m3->isPristine());
$m3 = new Memcached();
var_dump($m3->isPristine());