本文整理汇总了PHP中Cache::getCache方法的典型用法代码示例。如果您正苦于以下问题:PHP Cache::getCache方法的具体用法?PHP Cache::getCache怎么用?PHP Cache::getCache使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cache
的用法示例。
在下文中一共展示了Cache::getCache方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getLovedSongs
/**
* getLovedSongs()
* Gets user's loved songs. From cache file or from the feed.
*
* @return array $songs Returns formatted songs
*/
public static function getLovedSongs($username = '', $num_songs = 30)
{
if (!self::isValidUsername($username)) {
return array(self::$error);
}
// Check Feeder and Cache classes are accessible
if (!class_exists('Feeder')) {
return array('Could not find Feeder.class.php.');
}
if (!class_exists('Cache')) {
return array('Could not find Cache.class.php.');
}
self::$username = $username;
self::$num_songs = $num_songs;
$cache_filename = self::$username . '-loved-tracks.cache';
$cache_life = 86400;
// 1 day
Cache::init($cache_filename, $cache_life);
if (Cache::cacheFileExists()) {
return Cache::getCache();
}
$song_data = Feeder::getItems(self::getLovedSongsFeed(), self::$num_songs, array('title', 'link'));
if (!is_array($song_data)) {
self::$error = "Last.fm loved tracks feed not found";
return array(self::$error);
}
$songs = self::formatSongData($song_data);
Cache::setCache($songs);
return $songs;
}
示例2: word_stem
function word_stem($word)
{
$word = strtolower($word);
$cache = Cache::getCache('stemming');
if ($cache->has($word)) {
return $cache->get($word);
}
$stemmed = @stemm_es::stemm($word);
$cache->set($word, $stemmed);
return $stemmed;
}
示例3: getBooksFromShelf
/**
* getBooksFromShelf()
* Gets the array of books from a cache_file if found (and less than a week old).
* If no cache_file is found it creates this array of books and adds them to the cache_file - for fast loading next time
*
* @return array Returns a nicely formatted array of books
*/
private static function getBooksFromShelf()
{
$cache_filename = self::$goodreads_id . '-' . self::$shelf . '.cache';
$cache_life = 604800;
// 1 week
Cache::init($cache_filename, $cache_life);
if (Cache::cacheFileExists()) {
return Cache::getCache();
}
$book_data = Feeder::getItems(self::getGoodreadsFeed(), self::$num_books, array('title', 'author_name'));
if (!is_array($book_data)) {
self::$error = "Goodreads feed does not exist. Check user: " . self::$goodreads_id . " and shelf: '" . self::$shelf . "' exist";
return array(self::$error);
}
$books = self::formatBookData($book_data);
Cache::setCache($books);
return $books;
}
示例4: checkField
/**
* Check Field Values
* @param string $field IDX Field Name
* @return boolean
* @TODO Move this to IDX_Feed
*/
public static function checkField($field)
{
// IDX Feed
$idx = Util_IDX::getIdx();
$db_idx = Util_IDX::getDatabase();
// IDX Field
$field = $idx->field($field);
// Require Field
if (empty($field)) {
return false;
}
// Cache Key
$index = __METHOD__ . ':' . $idx->getName() . ':' . $db_idx->db() . ':' . $idx->getTable() . ':' . $field;
// Is Cached (Server-Wide)
$cache = static::$useCache && !static::$reCache ? Cache::getCache($index, true) : null;
if (!is_null($cache)) {
$check = $cache;
// Not Cached
} else {
// Check for Values
$check = $db_idx->fetchQuery("SELECT SQL_CACHE `" . $field . "` FROM `" . $idx->getTable() . "` WHERE `" . $field . "` IS NOT NULL AND `" . $field . "` != '' LIMIT 1;");
// Return Boolean
$check = !empty($check);
// Save Cache (Server-Wide)
if (static::$useCache || static::$reCache) {
Cache::setCache($index, $check, true);
}
}
// Return Check
return $check;
}
示例5: header
}
$Core->LoadUserPlugins();
$Core->trigger('OnBeforeInitPage');
$Core->DefineDefaultPage();
$html = "";
$errorPage = null;
if ($Filter->get($_GET, 'pid', DEFAULT_PAGE) == NOT_FOUND) {
if ($errorPage = $Router->pageNotFound()) {
$_GET['pid'] = $errorPage->id;
} else {
header("HTTP/1.0 404 Not Found");
die(NO_404_PAGE);
}
}
if ($Filter->get($config, 'use_cache', 0) && $Cache->isCached()) {
$html = $Cache->getCache();
}
if (empty($html)) {
$Skin = new Skin($Filter->get($_GET, 'pid', DEFAULT_PAGE));
$html = $Skin->getHtml();
$html = str_replace(TOKEN_SKYBLUE_INFO_LINK, SKYBLUE_INFO_LINK, $html);
$html = str_replace(TOKEN_BODY_CLASS, null, $html);
}
$html = $Core->trigger('OnBeforeShowPage', $html);
$html = $Core->trigger('OnRenderPage', $html);
if ($Filter->get($config, 'use_cache', 0)) {
$Cache->saveCache($html);
$html .= "\n<!-- page caching enabled -->\n";
}
if ($errorPage) {
header("HTTP/1.0 404 Not Found");
示例6: Config
/**
* Strip-It Rss
*
* @license http://www.gnu.org/licenses/gpl.html GPL
* @copyright 2009 Johann Dréo, Simon Leblanc
* @author Johann "nojhan" Dréo <nojhan@gmail.com>
* @author Simon Leblanc <contact@leblanc-simon.eu>
* @package stripit
*/
require_once 'inc/functions.php';
//Launch Cron
Cron::exec();
// Obtain the Config
$config = new Config();
// Obtain the cache
$cache = Cache::getCache();
// Obtain the id asked
$last = Cache::getLastId();
// Obtain the limit
if (isset($_GET['limit']) && is_numeric($_GET['limit'])) {
$limit = $_GET['limit'];
if ($limit <= 0 || $limit > $last + 1) {
$limit = $last + 1;
}
} else {
$limit = $last + 1;
}
$end = $last - $limit;
// Obtain the strips
$list = array();
for ($i = $last; $i > $end; $i--) {
示例7: Page
if (isset($theme) && $theme) {
$_SESSION['theme'] = $theme;
}
$page = new Page();
$movie = new Movie();
$show = new Show();
$cache = new Cache($basepath);
$misc = new Misc();
$request = new Request();
$plugins = new Plugins();
$hascache = 0;
$cache_writeable = $cache->checkDir();
if ($cache_writeable) {
$cachekey_plain = date("YmdH") . @$_SERVER['HTTP_HOST'] . @$_SERVER['REQUEST_URI'] . @json_encode($_GET) . @json_encode($_POST) . @json_encode($_SESSION) . @json_encode($_COOKIE) . "_" . $language;
$cachekey = md5($cachekey_plain);
$hascache = $cache->getCache($cachekey);
}
$hascache = 0;
if ($hascache) {
print $hascache;
} else {
@ob_start();
if (!isset($_SESSION['theme']) || !$_SESSION['theme']) {
$theme = $settings->getSetting("theme");
if (!count($theme)) {
$theme = 'svarog';
} else {
$theme = $theme->theme;
}
} else {
$theme = $_SESSION['theme'];
示例8: header
<?php
error_reporting(0);
include 'lib/core.class.php';
include 'lib/slickr.class.php';
include 'lib/cache.class.php';
@(include 'config.php');
if (!defined('USER')) {
header('Location: admin/install.php');
}
$slickr = new Slickr(USER);
$cache = new Cache($_SERVER['REQUEST_URI']);
$cache->getCache();
if (!empty($_GET['id'])) {
// on affiche les photos
list($images, $parent) = $slickr->getPhotos();
@(include 'templates/' . TEMPLATE . '/images.php');
} elseif (!empty($_GET['c_id'])) {
// on affiche des photosets
list($collecSets, $sets, $parent) = $slickr->getPhotosets();
@(include 'templates/' . TEMPLATE . '/collecphotosets.php');
} elseif (!empty($_GET['b_id'])) {
// on affiche des collections dans des collections
list($collections, $parent) = $slickr->getCollections();
$collections = $collections[$slickr->getBid()]['collection'];
@(include 'templates/' . TEMPLATE . '/collections.php');
} else {
// page par defaut
if (HOMEPAGE == 'collections') {
//(collections)
list($collections, $parent) = $slickr->getCollections();
示例9: array
require_once 'cache.php';
//error_reporting(0);
$result = array('status' => 'error_unknown');
if (!isset($_GET['term'])) {
$result['status'] = 'error_search_term';
$result['error'] = 'No search term was specified';
} else {
$queryResult = twitter_query($_GET['term']);
if (isset($queryResult['errors'])) {
$result['status'] = 'error_api';
$result['error'] = 'API returned errors';
$result['api_errors'] = $queryResult['errors'];
} else {
$result['status'] = 'ok';
$result['summary'] = array('positive' => 0, 'neutral' => 0, 'negative' => 0);
$stemCache = Cache::getCache('stemming');
$stemCache->load();
$lexicon = lexicon_stem(lexicon_read('lexicon.txt'));
$statuses = $queryResult['statuses'];
$result['tweets'] = process_tweets($statuses, $lexicon);
foreach ($result['tweets'] as $tweet) {
$val = array_sum($tweet['words']);
if ($val > 0.01) {
$result['summary']['positive']++;
} else {
if ($val < -0.01) {
$result['summary']['negative']++;
} else {
$result['summary']['neutral']++;
}
}
示例10: createCache
/**
* Create cache for one or all necessary strips
*
* @param string $file The filename of the strip for which we must regenerate cache or null if we must regenerate all cache file necessary
* @access public
* @static
*/
public static function createCache($file = null)
{
if ($file === null) {
// we must regenerate all SVG cache
$actual_cache = Cache::getCache();
Cache::setCache();
$new_cache = Cache::getCache();
$compare = array_diff($new_cache, $actual_cache);
foreach ($compare as $filename => $time) {
$strip = new Strip($filename, true);
$strip->setCache();
}
} else {
$strip = new Strip($file, true);
$strip->setCache();
}
}