當前位置: 首頁>>代碼示例>>PHP>>正文


PHP cache::factory方法代碼示例

本文整理匯總了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;
         }
     }
 }
開發者ID:henare,項目名稱:electionleaflets,代碼行數:28,代碼來源:constituencies.php

示例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;
 }
開發者ID:schlos,項目名稱:electionleaflets,代碼行數:14,代碼來源:analyze.php

示例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;
        }
    }
}
開發者ID:GetUp,項目名稱:Election-Leaflet-Project-Australia,代碼行數:18,代碼來源:map_uk_constituencies.php

示例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;
 }
開發者ID:henare,項目名稱:electionleaflets,代碼行數:19,代碼來源:search.php

示例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;
    }
}
開發者ID:henare,項目名稱:electionleaflets,代碼行數:12,代碼來源:functions.php

示例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;
 }
開發者ID:GetUp,項目名稱:Election-Leaflet-Project-Australia,代碼行數:14,代碼來源:tablebase.php

示例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;
 }
開發者ID:schlos,項目名稱:electionleaflets,代碼行數:14,代碼來源:tablebase.php


注:本文中的cache::factory方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。