本文整理汇总了PHP中cache::factory方法的典型用法代码示例。如果您正苦于以下问题:PHP cache::factory方法的具体用法?PHP cache::factory怎么用?PHP cache::factory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cache
的用法示例。
在下文中一共展示了cache::factory方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: lookup_constituency
private function lookup_constituency($postcode)
{
$cache = cache::factory();
$cached = $cache->get('twfy' . $postcode);
if (isset($cached) && $cached !== false && $cached != '') {
return $cached;
} else {
if (COUNTRY_CODE_TLD == "uk") {
$twfy = factory::create('twfy');
$twfy_constituency = $twfy->query('getConstituency', array('output' => 'php', 'postcode' => $postcode, 'future' => 'yes_please'));
$twfy_constituency = unserialize($twfy_constituency);
$success = $cache->set('twfy' . $postcode, $twfy_constituency);
$twfy_constituency = array($twfy_constituency["name"]);
} else {
if (COUNTRY_CODE_TLD == "au") {
$australian_postcode = factory::create("australian_postcode");
return $australian_postcode->lookup_constituency_names($postcode);
} else {
$success = false;
}
}
if ($success && isset($twfy_constituency) && $twfy_constituency != '' && $twfy_constituency != false) {
return $twfy_constituency;
} else {
return false;
}
}
}
示例2: get_leaflet_count
private function get_leaflet_count()
{
$return = 0;
$cache = cache::factory();
$cached = $cache->get("total_leaflet_count");
if ($cached !== false && isset($cached)) {
$return = $cached;
} else {
$leaflet = factory::create('leaflet');
$return = $leaflet->count();
$cache->set("total_leaflet_count", $return);
}
return $return;
}
示例3: lookup_constituency
function lookup_constituency($postcode)
{
$cache = cache::factory();
$cached = $cache->get('twfy' . $postcode);
if (isset($cached) && $cached !== false && $cached != '') {
return $cached;
} else {
$twfy = factory::create('twfy');
$twfy_constituency = $twfy->query('getConstituency', array('output' => 'php', 'postcode' => $postcode, 'future' => 'yes_please'));
$twfy_constituency = unserialize($twfy_constituency);
$success = $cache->set('twfy' . $postcode, $twfy_constituency);
if ($success && isset($twfy_constituency) && $twfy_constituency != '' && $twfy_constituency != false) {
return $twfy_constituency;
} else {
return false;
}
}
}
示例4: query_cached
public function query_cached($class_name, $sql)
{
$return = false;
//check the cache
$cache = cache::factory();
$cached = $cache->get($sql, "search");
//try and get from cache, if not, get from database
if (isset($cached) && $cached !== false) {
$return = $cached;
} else {
$return = $this->query($class_name, $sql);
//cache
$cached = $cache->set($sql, $return, "search");
if ($cached == false) {
trigger_error("Failed to cache database call");
}
}
return $return;
}
示例5: safe_scrape_cached
function safe_scrape_cached($url)
{
$cache = cache::factory();
$cached = $cache->get($url);
if (isset($cached) && $cached !== false) {
return $cached;
} else {
$page = safe_scrape($url);
$cache->set($url, $page, "safe_scrape");
return $page;
}
}
示例6: execute_cached
public function execute_cached($sql)
{
$return = null;
$cache = cache::factory();
$cached = $cache->get($key, "execute");
//if we have something in the cache, grab that, if not do the query as normal
if (isset($cached) && $cached !== false) {
$return = $cached;
} else {
$return = $this->execute($sql);
$cached = $cache->set($key, $return, "execute");
}
return $return;
}
示例7: count_cached
public function count_cached()
{
$return = null;
$cache = cache::factory();
$key = serialize($this);
$cached = $cache->get($key, "count");
//if we have something in the cache, grab that, if not do the query as normal
if (isset($cached) && $cached !== false) {
$return = $cached;
} else {
$return = $this->count();
}
return $return;
}