当前位置: 首页>>代码示例>>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;未经允许,请勿转载。