本文整理汇总了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());