当前位置: 首页>>代码示例>>PHP>>正文


PHP Cache::exists方法代码示例

本文整理汇总了PHP中Cache::exists方法的典型用法代码示例。如果您正苦于以下问题:PHP Cache::exists方法的具体用法?PHP Cache::exists怎么用?PHP Cache::exists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Cache的用法示例。


在下文中一共展示了Cache::exists方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testExistsNoToString

 public function testExistsNoToString()
 {
     $object = new CacheTestNoToSTring();
     $cache = new Cache();
     $this->setExpectedException('PHPUnit_Framework_Error');
     $cache->exists($object);
 }
开发者ID:aurmil,项目名称:dflydev-placeholder-resolver,代码行数:7,代码来源:CacheTest.php

示例2: load

 /**
  * 
  * @param $model
  * @param $serviceClass
  * @return Model
  */
 public static function load($model, $path = null)
 {
     global $redirectedPackage;
     $modelName = (substr($model, 0, 1) == "." ? $redirectedPackage : "") . $model;
     if (!isset(Model::$instances[$modelName])) {
         if (!Cache::exists("model_{$modelName}")) {
             Model::$instances[$modelName] = Cache::add("model_{$modelName}", Model::loadModelClass($model, $path));
         } else {
             add_include_path(Cache::get("model_path_{$modelName}"), false);
             Model::$instances[$modelName] = Cache::get("model_{$modelName}");
         }
     }
     return Model::$instances[$modelName];
 }
开发者ID:ekowabaka,项目名称:wyf,代码行数:20,代码来源:Model.php

示例3: getObjectTag

 /**
  * Get object tag
  *
  * @param string $group_id Group
  *
  * @return string|null
  */
 static function getObjectTag($group_id = null)
 {
     // Recherche de l'établissement
     $group = CGroups::get($group_id);
     if (!$group_id) {
         $group_id = $group->_id;
     }
     $cache = new Cache(__METHOD__, array($group_id), Cache::INNER);
     if ($cache->exists()) {
         return $cache->get();
     }
     $tag = self::getDynamicTag();
     return $cache->put(str_replace('$g', $group_id, $tag));
 }
开发者ID:OpenXtrem,项目名称:mediboard_save,代码行数:21,代码来源:CHL7.class.php

示例4: loadList

 /**
  * Chargement de a liste des dents disponibles
  *
  * @return self[] Liste des dents
  */
 static function loadList()
 {
     $cache = new Cache(__METHOD__, func_get_args(), Cache::INNER_OUTER);
     if ($cache->exists()) {
         return $cache->get();
     }
     $ds = self::getSpec()->ds;
     $query = "SELECT t_localisationdents.*\n      FROM t_localisationdents\n      ORDER BY t_localisationdents.LOCDENT ASC,\n        t_localisationdents.DATEFIN ASC";
     $result = $ds->exec($query);
     $listDents = array();
     while ($row = $ds->fetchArray($result)) {
         $dent = new CDentCCAM();
         $dent->map($row);
         $dent->loadLibelle();
         $listDents[$row["DATEFIN"]][] = $dent;
     }
     return $cache->put($listDents);
 }
开发者ID:fbone,项目名称:mediboard4,代码行数:23,代码来源:CDentCCAM.class.php

示例5: isEnabled

 /**
  * Is HTML-caching enabled (either globally or for $url)?
  * 
  * @param string  $url  URL to check specifically for
  * @return bool
  */
 public function isEnabled($url)
 {
     // check to see if html-caching is on
     $global_enable = (bool) $this->fetchConfig('enable', false, null, true);
     if (!$global_enable || !Cache::exists()) {
         return false;
     }
     // check that the URL being requested is a content file
     $data = ContentService::getContent($this->removeQueryString($url));
     // not a content file, not enabled
     if (!$data) {
         return false;
     }
     // check for exclude on the current page
     $exclude_raw = $this->fetchConfig('exclude');
     // if excludes were set
     if ($exclude_raw) {
         $excluded = Parse::pipeList($exclude_raw);
         // loop through excluded options
         foreach ($excluded as $exclude) {
             // account for non-/-starting locations
             $this_url = substr($exclude, 0, 1) !== "/" ? ltrim($url, '/') : $url;
             if ($exclude === "*" || $exclude === "/*") {
                 // exclude all
                 return false;
             } elseif (substr($exclude, -1) === "*") {
                 // wildcard check
                 if (strpos($this_url, substr($exclude, 0, -1)) === 0) {
                     return false;
                 }
             } else {
                 // plain check
                 if ($exclude == $this_url) {
                     return false;
                 }
             }
         }
     }
     // all is well, return true
     return true;
 }
开发者ID:zane-insight,项目名称:WhiteLaceInn,代码行数:47,代码来源:tasks.html_caching.php

示例6: get

 /**
  * Récupère le contenu d'une page ou le contenu d'un fichier de cache
  * @param string $url URL de la page
  * @return array Contenu + timestamp de la page $url
  */
 public static function get($url)
 {
     $datas = new stdClass();
     $fileName = '/' . preg_replace('/https?:\\/\\//', '', $url);
     curl_setopt(self::$ch, CURLOPT_URL, $url);
     // On check si le fichier n'existe pas ou s'il a expiré
     if (!Cache::exists($fileName) || Cache::hasExpired($fileName)) {
         $datas->url = $url;
         $datas->timestamp = time();
         $datas->content = curl_exec(self::$ch);
         $datas->info = curl_getinfo(self::$ch);
         $datas->httpCode = $datas->info['http_code'];
         $datas->error = curl_error(self::$ch);
         $datas->errno = curl_errno(self::$ch);
         Cache::set($fileName, serialize($datas));
         $datas->content = json_decode($datas->content);
     }
     // Si on a déjà un cache de dispo
     if (empty((array) $datas)) {
         $datas = Cache::get($fileName);
         $datas->content = json_decode($datas->content);
     }
     return $datas;
 }
开发者ID:Kocal,项目名称:LoLAPI,代码行数:29,代码来源:class.Curl.php

示例7: lookupEpisode

 public function lookupEpisode($seriesid, $show)
 {
     //http://www.thetvdb.com/api/5F84ECB91B42D719/series/78804/default/1/1
     $season = ltrim(str_replace('S', '', $show['season']), '0');
     $ep = ltrim(str_replace('E', '', $show['episode']), '0');
     $cache = new Cache();
     $apiresponse = false;
     $url = $this->MIRROR . '/api/' . self::APIKEY . '/series/' . $seriesid . '/default/' . $season . "/" . $ep;
     if ($cache->exists($url)) {
         $apiresponse = $cache->fetch($url);
     }
     if (!$apiresponse) {
         $apiresponse = getUrl($url);
     }
     if ($apiresponse) {
         $TheTVDBAPIXML = @simplexml_load_string($apiresponse);
         if (!$TheTVDBAPIXML) {
             return false;
         }
         $cache->store($url, $apiresponse);
         return array('id' => (string) $TheTVDBAPIXML->Episode->id, 'summary' => (string) $TheTVDBAPIXML->Episode->Overview, 'name' => (string) $TheTVDBAPIXML->Episode->EpisodeName, 'director' => (string) $TheTVDBAPIXML->Episode->Director, 'epabsolute' => (string) $TheTVDBAPIXML->Episode->absolute_number, 'writer' => (string) $TheTVDBAPIXML->Episode->Writer, 'gueststars' => (string) $TheTVDBAPIXML->Episode->GuestStars, 'rating' => (int) $TheTVDBAPIXML->Episode->Rating, 'airdate' => (string) $TheTVDBAPIXML->Episode->FirstAired, 'season' => $season, 'number' => (string) $TheTVDBAPIXML->Episode->EpisodeNumber);
     }
     return false;
 }
开发者ID:scriptzteam,项目名称:newzNZB-premium-indexer,代码行数:24,代码来源:thetvdb.php

示例8: api_fetch

function api_fetch($part, $ttl = false)
{
    $f3 = \Base::instance();
    $url = $f3->get("_api_url");
    $url = $url . "/api/" . $part;
    $apiHits = $f3->get("_api_hits");
    $apiHits[] = $url;
    $f3->set("_api_hits", $apiHits);
    $key = md5($url);
    $cache = new \Cache($key);
    //test_array($url);
    if ($cache->exists($key) && $ttl) {
        $data = json_decode($cache->get($key), true);
    } else {
        $web = new \Web();
        $data = $web->request($url);
        $data = json_decode($data['body'], true);
        $ddata = json_encode($data);
        $cache->set($key, $ddata, $ttl);
    }
    //test_array($data);
    //$url = substr($url,strpos($url,"."));
    return $data;
}
开发者ID:WilliamStam,项目名称:LiN-Basic,代码行数:24,代码来源:functions.php

示例9: load

 /**
  * 
  * @param $model
  * @param $serviceClass
  * @return Model
  */
 public static function load($model, $path = null, $cached = true)
 {
     global $redirectedPackage;
     global $packageSchema;
     $modelName = (substr($model, 0, 1) == "." ? $redirectedPackage : "") . $model;
     if (!isset(Model::$instances[$modelName])) {
         if ($cached && CACHE_MODELS) {
             if (!Cache::exists("model_{$modelName}")) {
                 Model::$instances[$modelName] = Cache::add("model_{$modelName}", Model::_load($model, $path));
             } else {
                 add_include_path(Cache::get("model_path_{$modelName}"), false);
                 $modelInstance = Cache::get("model_{$modelName}");
                 if ($redirectedPackage == '') {
                     $redirectedPackage = $modelInstance->redirectedPackage;
                     $packageSchema = $modelInstance->packageSchema;
                 }
                 Model::$instances[$modelName] = $modelInstance;
             }
         } else {
             Model::$instances[$modelName] = Model::_load($model, $path);
         }
     }
     return Model::$instances[$modelName];
 }
开发者ID:9naQuame,项目名称:wyf,代码行数:30,代码来源:Model.php

示例10: searchDirect

 /**
  * Query the indexer directly.  Returns an array of the results, unless
  * there was an error in which case ``false`` is returned.  However, if
  * Sphinx returns an "invalid query" error (1064), then an empty result
  * array is returned.  Note that an empty "result array" is not the same as
  * an empty array and will instead look like::
  *
  *      array({"_totalrows": 0})
  *
  * If  ``$lookupQuery`` is an empty string, then the results returned will
  * be the data from the index--this is not guaranteed to be the most recent
  * data that is in the MySQL database.  If you absolutely need the most
  * recent data from MySQL, then ``$lookupQuery`` should be a valid SQL
  * query that has contains "releases.ID IN (%s)".
  *
  * @param   string      $sphinxQuery    The raw SphinxQL query.
  * @param   string      $lookupQuery    The SQL to use to lookup the results.
  * @param   bool/int    $useCache    	The ttl to store the item in the cache.
  * @return  array|false
  */
 public function searchDirect($sphinxQuery, $lookupQuery = "", $useCache = false)
 {
     $cache = new Cache();
     if ($useCache !== false && $cache->enabled && $cache->exists($sphinxQuery)) {
         $ret = $cache->fetch($sphinxQuery);
         if ($ret !== false) {
             return $ret;
         }
     }
     // Connect to Sphinx
     $hostport = explode(":", $this->site->sphinxserverhost);
     $sdb = mysqli_connect($hostport[0], "root", "", "", $hostport[1]);
     if (!$sdb) {
         // Couldn't connect to Sphinx.
         return false;
     }
     // Get the results from Sphinx.
     $lev = error_reporting();
     error_reporting(0);
     $result = mysqli_query($sdb, $sphinxQuery);
     error_reporting($lev);
     $error = mysqli_error($sdb);
     // A 1064 error means that the query is invalid, so we don't care
     // about that.
     if ($error && mysqli_errno($sdb) != 1064) {
         // All other errors we will considered a failure.
         return false;
     }
     // Get the query metadata.
     $meta = array();
     $mresult = mysqli_query($sdb, "SHOW META");
     if (!$mresult) {
         return false;
     }
     while ($row = mysqli_fetch_row($mresult)) {
         $meta[$row[0]] = $row[1];
     }
     $results = array();
     if ($result) {
         while ($row = mysqli_fetch_assoc($result)) {
             if ($lookupQuery) {
                 // Save the IDs for a batch lookup.
                 $results[] = $row["id"];
             } else {
                 $results[] = $row;
             }
         }
     }
     if ($lookupQuery && count($results) > 0) {
         $ndb = new DB();
         $sql = sprintf($lookupQuery, implode(",", $results));
         $result = $ndb->queryDirect($sql);
         if ($result) {
             $results = array();
             while ($row = $ndb->getAssocArray($result)) {
                 $results[] = $row;
             }
         }
     }
     $count = 0;
     if (count($results) > 0 && array_key_exists("total", $meta)) {
         $count = (int) $meta["total_found"];
         $results[0]["_totalrows"] = $count > MAX_MATCHES ? MAX_MATCHES : $count;
     }
     if ($useCache !== false && $cache->enabled) {
         $cache->store($sphinxQuery, $results, $useCache);
     }
     return $results;
 }
开发者ID:scriptzteam,项目名称:newzNZB-premium-indexer,代码行数:89,代码来源:sphinx.php

示例11: fetchCache

 public function fetchCache($key)
 {
     $cache = new Cache();
     if ($cache->enabled && $cache->exists($key)) {
         $ret = $cache->fetch($key);
         if ($ret !== false) {
             return $ret;
         }
     }
     return false;
 }
开发者ID:scriptzteam,项目名称:newzNZB-premium-indexer,代码行数:11,代码来源:tvmaze.php

示例12: get

 /**
  * Chargement optimisé des codes CCAM
  *
  * @param string $code Code CCAM
  * @param int    $niv  Niveau du chargement
  *
  * @return COldCodeCCAM
  */
 static function get($code, $niv = self::MEDIUM)
 {
     $cache = new Cache(__METHOD__, func_get_args(), Cache::INNER_OUTER);
     if ($cache->exists()) {
         return $cache->get();
     }
     // Chargement
     $code_ccam = new COldCodeCCAM($code);
     $code_ccam->load($niv);
     return $cache->put($code_ccam, true);
 }
开发者ID:fbone,项目名称:mediboard4,代码行数:19,代码来源:COldCodeCCAM.class.php

示例13: exist

 /**
  * Inform whether formerly cached value of caller fonction is available
  *
  * @param array $context Context as (methode name, array of params)
  *
  * @return bool
  * @deprecated Use Cache::exists() non-static method instead
  */
 static function exist($context)
 {
     list($function, $args) = $context;
     $cache = new Cache($function, $args, Cache::INNER);
     return $cache->exists();
 }
开发者ID:OpenXtrem,项目名称:mediboard-test,代码行数:14,代码来源:CFunctionCache.class.php

示例14: intval

include_once "{$lib}/share/link.php";
include_once "{$lib}/share/stdio.php";
include_once "{$lib}/share/string.php";
pieLoadLocale();
pieHead();
$_REQUEST['limit'] = intval(@$_REQUEST['limit']);
if ($_REQUEST['limit'] < 1) {
    $_REQUEST['limit'] = 10;
}
if ($_REQUEST['limit'] > 100) {
    $_REQUEST['limit'] = 100;
}
$page = new Page();
$cache = new Cache();
$cid = $cache->key('latest', array());
if ($GLOBALS['pie']['query_caching'] && $cache->exists($cid)) {
    // Use existing cache.
    $dump = trim(file_get_contents($cache->file($cid)));
    $cache->update($cid);
    $dump = explode("\n", $dump);
    $data = array();
    foreach ($dump as $i) {
        $data[] = $i;
    }
} else {
    // Determine latest page changes.
    $data = array();
    for ($name = $page->first(); $name; $name = $page->next()) {
        $data[] = $page->stamp . "\t{$name}";
    }
    rsort($data);
开发者ID:rafsoaken,项目名称:piewiki,代码行数:31,代码来源:latest.php

示例15: testDoesNotExpire

 /**
  * @covers RyzomExtra\Cache::set
  * @covers RyzomExtra\Cache::expired
  */
 public function testDoesNotExpire()
 {
     $key = 'test-does-not-expire';
     $cache = new Cache($this->cachePath);
     $this->assertFalse($cache->exists($key), 'Cache file was found');
     $cache->set($key, '1234');
     $this->assertTrue($cache->exists($key), 'Cache file was not created');
     $this->assertFalse($cache->expired($key));
 }
开发者ID:wushepeng,项目名称:guildinformations,代码行数:13,代码来源:CacheTest.php


注:本文中的Cache::exists方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。