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


PHP Cache_Lite::get方法代码示例

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


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

示例1: get

 /**
  * Get cached data by ID and group
  *
  * @param   string   $id         The cache data ID
  * @param   string   $group      The cache data group
  * @param   boolean  $checkTime  True to verify cache time expiration threshold
  *
  * @return  mixed  Boolean false on failure or a cached data object
  *
  * @since   11.1
  */
 public function get($id, $group, $checkTime = true)
 {
     static::$CacheLiteInstance->setOption('cacheDir', $this->_root . '/' . $group . '/');
     // This call is needed to ensure $this->rawname is set
     $this->_getCacheId($id, $group);
     return static::$CacheLiteInstance->get($this->rawname, $group);
 }
开发者ID:joomla-projects,项目名称:media-manager-improvement,代码行数:18,代码来源:cachelite.php

示例2: getData

 public function getData()
 {
     $Cache_Lite = new Cache_Lite(parent::getCacheOptions());
     $url = sprintf('https://readitlaterlist.com/v2/get?username=%s&password=%s&apikey=%s&count=%s&format=json', $this->config['username'], $this->config['password'], $this->config['apikey'], $this->config['total']);
     $id = $url;
     if ($data = $Cache_Lite->get($id)) {
         $data = json_decode($data);
     } else {
         $Cache_Lite->get($id);
         PubwichLog::log(2, Pubwich::_('Rebuilding cache for a Readitlater'));
         PubwichLog::log(2, $this->url);
         $data = file_get_contents($url);
         $data = json_decode($data);
         foreach ($data->list as $item) {
             // Default value
             $item->title = parse_url($item->url, PHP_URL_HOST);
             // If check page title
             if (!empty($this->config['getTitle'])) {
                 $file = @fopen($item->url, "r");
                 if ($file) {
                     $text = fread($file, 1024 * 3);
                     if (preg_match('/<title>(.*?)<\\/title>/is', $text, $found)) {
                         $item->title = $found[1];
                     }
                 }
             }
         }
         // Write cache
         $cacheWrite = $Cache_Lite->save(json_encode($data));
     }
     return $data->list;
 }
开发者ID:msqueeg,项目名称:PubwichFork,代码行数:32,代码来源:Readitlater.php

示例3: retrieveFile

 /**
  * Retrieves data from cache, if it's there.  If it is, but it's expired,
  * it performs a conditional GET to see if the data is updated.  If it
  * isn't, it down updates the modification time of the cache file and
  * returns the data.  If the cache is not there, or the remote file has been
  * modified, it is downloaded and cached.
  *
  * @param string URL of remote file to retrieve
  * @param int Length of time to cache file locally before asking the server
  *            if it changed.
  * @return string File contents
  */
 function retrieveFile($url, $cacheLength, $cacheDir)
 {
     $cacheID = md5($url);
     $cache = new Cache_Lite(array("cacheDir" => $cacheDir, "lifeTime" => $cacheLength));
     if ($data = $cache->get($cacheID)) {
         return $data;
     } else {
         // we need to perform a request, so include HTTP_Request
         include_once 'HTTP/Request.php';
         // HTTP_Request has moronic redirect "handling", turn that off (Alexey Borzov)
         $req = new HTTP_Request($url, array('allowRedirects' => false));
         // if $cache->get($cacheID) found the file, but it was expired,
         // $cache->_file will exist
         if (isset($cache->_file) && file_exists($cache->_file)) {
             $req->addHeader('If-Modified-Since', gmdate("D, d M Y H:i:s", filemtime($cache->_file)) . " GMT");
         }
         $req->sendRequest();
         if (!($req->getResponseCode() == 304)) {
             // data is changed, so save it to cache
             $data = $req->getResponseBody();
             $cache->save($data, $cacheID);
             return $data;
         } else {
             // retrieve the data, since the first time we did this failed
             if ($data = $cache->get($cacheID, 'default', true)) {
                 return $data;
             }
         }
     }
     Services_ExchangeRates::raiseError("Unable to retrieve file {$url} (unknown reason)", SERVICES_EXCHANGERATES_ERROR_RETRIEVAL_FAILED);
     return false;
 }
开发者ID:Spark-Eleven,项目名称:revive-adserver,代码行数:44,代码来源:Common.php

示例4: get

 /**
  * A method to get the permanent cache content
  *
  * @param string $cacheName The name of the original file we are retrieving
  * @return mixed The cache content or FALSE in case of cache miss
  */
 function get($cacheName)
 {
     if (extension_loaded('zlib')) {
         $id = $this->_getId($cacheName);
         $group = $this->_getGroup($cacheName);
         if ($result = $this->oCache->get($id, $group, true)) {
             return unserialize(gzuncompress($result));
         }
     }
     return false;
 }
开发者ID:Spark-Eleven,项目名称:revive-adserver,代码行数:17,代码来源:PermanentCache.php

示例5: Cacheing

 public function Cacheing($url, $flag, $date, $time = 360)
 {
     $cacheoptions = array('caching' => true, 'lifeTime' => $time, 'automaticCleaningFactor' => '100', 'cacheDir' => dirname(__FILE__) . '/nicocache/cache/');
     $CacheLite = new Cache_Lite($cacheoptions);
     $returndate;
     switch ($flag) {
         case TRUE:
             if ($filedate = $CacheLite->get($url)) {
                 switch ($date) {
                     case "xml":
                         $xml = simplexml_load_string($filedate, 'SimpleXMLElement', LIBXML_NOCDATA);
                         if ($xml) {
                             $returndate = $xml;
                         } else {
                             $returndate = $filedate;
                         }
                         break;
                     case "html":
                         $returndate = $filedate;
                         break;
                 }
             } else {
                 $returndate = FALSE;
             }
             break;
         case FALSE:
             if ($CacheLite->save($date, $url)) {
                 $returndate = TRUE;
             } else {
                 $returndate = FALSE;
             }
             break;
     }
     return $returndate;
 }
开发者ID:NsProject,项目名称:NicoSubLine-OPNE-,代码行数:35,代码来源:nicoclass.php

示例6: transaction

function transaction($sql)
{
    global $response, $apiKey, $data, $basePath;
    $parsedSQL = SqlParser::ParseString($sql)->getArray();
    //$tokens = SqlParser::Tokenize($sql, true);
    if (strpos($sql, ';') !== false) {
        $response['success'] = false;
        $response['message'] = "You can't use ';'. Use the bulk transaction API instead";
    } elseif (strpos($sql, '--') !== false) {
        $response['success'] = false;
        $response['message'] = "SQL comments '--' are not allowed";
    } elseif ($parsedSQL['drop']) {
        $response['success'] = false;
        $response['message'] = "DROP is not allowed through the API";
    } elseif ($parsedSQL['alter']) {
        $response['success'] = false;
        $response['message'] = "ALTER is not allowed through the API";
    } elseif ($parsedSQL['create']) {
        $response['success'] = false;
        $response['message'] = "CREATE is not allowed through the API";
    } elseif ($parsedSQL['update'] || $parsedSQL['insert'] || $parsedSQL['delete']) {
        if ($apiKey == $_REQUEST['key'] || $apiKey == false) {
            $api = new sqlapi();
            $response = $api->transaction($_REQUEST['q']);
        } else {
            $response['success'] = false;
            $response['message'] = "Not the right key!";
        }
    } elseif ($parsedSQL['select']) {
        parse_str(urldecode($_SERVER['QUERY_STRING']), $args);
        $id = $args['q'];
        if (!$args['lifetime']) {
            $args['lifetime'] = 0;
        }
        $options = array('cacheDir' => "{$basePath}/tmp/", 'lifeTime' => $args['lifetime']);
        $Cache_Lite = new Cache_Lite($options);
        if ($data = $Cache_Lite->get($id)) {
            //echo "cached";
        } else {
            ob_start();
            if ($_REQUEST['srs']) {
                $srs = $_REQUEST['srs'];
            } else {
                $srs = "900913";
            }
            $api = new sqlapi($srs);
            $api->execQuery("set client_encoding='UTF8'", "PDO");
            $response = $api->sql($_REQUEST['q']);
            echo json_encode($response);
            // Cache script
            $data = ob_get_contents();
            $Cache_Lite->save($data, $id);
            ob_get_clean();
        }
    } else {
        $response['success'] = false;
        $response['message'] = "Check your SQL. Could not recognise it as either SELECT, INSERT, UPDATE or DELETE";
    }
    return $response;
}
开发者ID:valentijnvenus,项目名称:geocloud,代码行数:60,代码来源:sql_c.php

示例7: versionCheck

 /**
  * versionCheck - Get the most current version of nterchange and cache the result.
  *
  * @return 	array 	Information about the newest version of nterchange.
  **/
 function versionCheck()
 {
     require_once 'Cache/Lite.php';
     $options = array('cacheDir' => CACHE_DIR . '/ntercache/', 'lifeTime' => $this->check_version_interval);
     $cache = new Cache_Lite($options);
     $yaml = $cache->get($this->cache_name, $this->cache_group);
     if (empty($yaml)) {
         include_once 'HTTP/Request.php';
         $req = new HTTP_Request($this->check_version_url);
         if (!PEAR::isError($req->sendRequest())) {
             $yaml = $req->getResponseBody();
             $cached = $cache->save($yaml, $this->cache_name, $this->cache_group);
             if ($cached == true) {
                 NDebug::debug('Version check - data is from the web and is now cached.', N_DEBUGTYPE_INFO);
             } else {
                 NDebug::debug('Version check - data is from the web and is NOT cached.', N_DEBUGTYPE_INFO);
             }
         }
     } else {
         NDebug::debug('Version check - data is from the cache.', N_DEBUGTYPE_INFO);
     }
     require_once 'vendor/spyc.php';
     $newest_version_info = @Spyc::YAMLLoad($yaml);
     return $newest_version_info;
 }
开发者ID:nonfiction,项目名称:nterchange,代码行数:30,代码来源:version_check_controller.php

示例8: minify

 private static function minify($arrFilter)
 {
     $strOutput = "";
     if (is_dir($GLOBALS["_PATHS"]['js'])) {
         //*** Directory exists.
         foreach ($arrFilter as $strFilter) {
             $strFile = $GLOBALS["_PATHS"]['js'] . $strFilter . ".js";
             if (is_file($strFile)) {
                 $strOutput .= @file_get_contents($strFile) . "\n";
             }
         }
     }
     //*** Minify the Javascript and cache the result.
     $strHash = md5(implode(",", $arrFilter));
     $objCache = new \Cache_Lite($GLOBALS["_CONF"]["cache"]);
     $strReturn = $objCache->get($strHash, "js");
     if ($strReturn) {
         $strOutput = $strReturn;
     } else {
         if ($GLOBALS["_CONF"]["cache"]["caching"]) {
             $strOutput = \JSMin::minify($strOutput);
         }
         $objCache->save($strOutput, $strHash, "js");
     }
     return $strOutput;
 }
开发者ID:rvanbaalen,项目名称:bili,代码行数:26,代码来源:JSIncluder.php

示例9: isDoubleCcTld

 /**
  * Check if the last two parts of the FQDN are whitelisted.
  *
  * @param  string Host to check if it is whitelisted
  * @access protected
  * @return boolean True if the host is whitelisted
  */
 function isDoubleCcTld($fqdn)
 {
     // 30 Days should be way enough
     $options = array('lifeTime' => '2592000', 'automaticSerialization' => true);
     $id = md5($this->doubleCcTldFile);
     $cache = new Cache_Lite($options);
     if ($data = $cache->get($id)) {
         // Cache hit
     } else {
         // Cache miss
         $http = new HTTP_Request($this->doubleCcTldFile);
         if (!PEAR::isError($http->sendRequest())) {
             $data = $http->getResponseBody();
         }
         $data = explode("\n", $data);
         $data = array_flip($data);
         $cache->save($data, $id);
     }
     // if
     if (array_key_exists($fqdn, $data)) {
         return true;
     } else {
         return false;
     }
     // if
 }
开发者ID:vonnordmann,项目名称:Serendipity,代码行数:33,代码来源:SURBL.php

示例10: array

 function _list_output()
 {
     $sm = vivvo_lite_site::get_instance();
     $content_template = $this->load_template($this->_template_root . 'content.xml');
     require_once VIVVO_FS_FRAMEWORK . '/PEAR/Lite.php';
     $options = array('cacheDir' => VIVVO_FS_ROOT . 'cache/', 'lifeTime' => 600);
     $cache_manager = new Cache_Lite($options);
     $web_stat = $cache_manager->get('web_statistics', 'admin');
     if (empty($web_stat)) {
         $web_stat = $this->web_statistics();
         $cache_manager->save($web_stat, 'web_statistics', 'admin');
     }
     $system_stat = $cache_manager->get('system_statistics', 'admin');
     if (empty($system_stat)) {
         $system_stat = $this->system_statistics();
         $cache_manager->save($system_stat, 'system_statistics', 'admin');
     }
     $today_stat = $cache_manager->get('today_statistics', 'admin');
     if (empty($today_stat)) {
         $today_stat = $this->today_statistics();
         $cache_manager->save($today_stat, 'today_statistics', 'admin');
     }
     $signup_stat = $cache_manager->get('signup_statistics', 'admin');
     if (empty($signup_stat)) {
         $signup_stat = $this->signup_statistics();
         $cache_manager->save($signup_stat, 'signup_statistics', 'admin');
     }
     $content_template->assign('web_statistics', $web_stat);
     $content_template->assign('system_statistics', $system_stat);
     $content_template->assign('today_statistics', $today_stat);
     $content_template->assign('signup_statistics', $signup_stat);
     $log_file = VIVVO_FS_ROOT . VIVVO_FS_FILES_DIR . 'logs/' . date('Y') . '-' . date('m') . '.txt';
     $handle = @fopen($log_file, "r");
     if ($handle) {
         $i = 0;
         while (!feof($handle) && $i < 10) {
             $buffer .= str_replace(',', ', ', str_replace('"', '', fgets($handle, 4096)));
             $i++;
         }
         fclose($handle);
         $content_template->assign('activity_log', strval($buffer));
     } else {
         $content_template->assign('activity_log', strval(''));
     }
     $content_template->assign('activity_log_link', strval(VIVVO_URL . VIVVO_FS_ADMIN_DIR . 'download.php?file=' . VIVVO_FS_FILES_DIR . 'logs/' . date('Y') . '-' . date('m') . '.txt'));
     return $content_template;
 }
开发者ID:ahanjir07,项目名称:vivvo-dev,代码行数:47,代码来源:dashboard_admin_view.class.php

示例11: get

 public function get()
 {
     global $config;
     if ($config['cache']['disable']) {
         return false;
     }
     return parent::get($this->cache_id, $this->cache_group);
 }
开发者ID:brokencube,项目名称:hodgepodge,代码行数:8,代码来源:CacheLite.php

示例12: HandleDownloadStat

function HandleDownloadStat()
{
    require_once "Http_Cache.php";
    Http_Cache::setExpires(4 * 60 * 60);
    require_once "Cache/Lite.php";
    print " ";
    $options = array("cacheDir" => "../tmpcache/", "lifeTime" => 4 * 60 * 60);
    $cacheLite = new Cache_Lite($options);
    if ($data = $cacheLite->get("downloadStat")) {
        print $data;
    } else {
        require_once "TreeUtils.php";
        require_once "RubricsData.php";
        $rubrics = new RubricsData();
        ob_start();
        list($days1, $days2) = $rubrics->getDayNums(true);
        print '
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
<html><head><title>Статистика скачиваний</title>
<meta http-equiv="content-type" content="text/html; charset=windows-1251">
<meta name="description" content="">
<meta name="keywords" content="">
<link type="text/css" rel="stylesheet" href="styles/style.css">
</head>
<body><div id="container" class="stats"><div id="page">
<div id="content">
<div id="header">
<a href="./categs.html">Категории</a> &nbsp; 
| &nbsp; <a href="./tasks.html">Журнал обновлений</a> &nbsp; 
| &nbsp; <a href="./stat.html"><b>Статистика скачиваний</b></a></div>

<div id="main_content">
<h1>Статистика скачиваний</h1>
<strong style="font-size: 11px;">Обновление статистики производится ежедневно после 06.00, 12.00, 16.00, 20.00, 00.00 часов.</strong>
<br><br><br>
<p>Количество скаченных компаний, вчера - ' . $days1 . '</p>
<p>Количество скаченных компаний, сегодня - ' . $days2 . '</p>
<br><br>		
<table>
<thead>
<thead>
<tr><th>Номер</th><th>Название</th><th>Количество<br>скачанных</th><th>Количество в источнике</th><td>Осталось,<br>%</td><td>Email</td><td>Email,<br>%</td><td>Разница</td><td>Последнее обновление</td></tr>
</thead>
<tbody>
';
        processRubrics($rubrics);
        print '
</tbody>
</table>
</div>
</div></div></div><div id="footer"></div>
</body></html>
';
        $data = ob_get_contents();
        ob_end_clean();
        $cacheLite->save($data);
    }
}
开发者ID:rivetweb,项目名称:old-yellowpages-grabber,代码行数:58,代码来源:HandleDownloadStat.php

示例13: getTreeAsSelect

 function getTreeAsSelect()
 {
     $cache = new Cache_Lite(array('cacheDir' => CACHE_DIR . '/ntercache/', 'lifeTime' => 3600 * 24 * 7));
     $nodes = $cache->get('treeasselect', 'default');
     if (!$nodes) {
         return;
     }
     return unserialize($nodes);
 }
开发者ID:nonfiction,项目名称:nterchange,代码行数:9,代码来源:n_cache.php

示例14: getCache

 /**
  * 读取Cache文件
  * @param Cache_Lite $oCache
  * @param string $id
  * @param string $group
  */
 public static function getCache($oCache, $id, $group)
 {
     if (extension_loaded('zlib')) {
         if ($result = $oCache->get($id, $group, true)) {
             return unserialize(gzuncompress($result));
         }
     }
     return false;
 }
开发者ID:siiwi,项目名称:siiwi.com,代码行数:15,代码来源:utils.php

示例15: get

 function get($id)
 {
     $mtime = $this->dbmtime();
     $this->_setFileName($id, 'default');
     if ($mtime < $this->lastModified()) {
         return parent::get($id);
     } else {
         return false;
     }
 }
开发者ID:minger11,项目名称:Pipeline,代码行数:10,代码来源:PageCache.php


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