本文整理汇总了PHP中Cache::store方法的典型用法代码示例。如果您正苦于以下问题:PHP Cache::store方法的具体用法?PHP Cache::store怎么用?PHP Cache::store使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cache
的用法示例。
在下文中一共展示了Cache::store方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: cacheTree
public static function cacheTree($path, $force = false)
{
// split path into array
if (is_string($path)) {
$path = Site::splitPath($path);
}
// check if this tree has already been cached
$cacheKey = 'cacheTree:' . implode('/', $path);
if (!Site::$autoPull || !$force && Cache::fetch($cacheKey)) {
return 0;
}
Cache::store($cacheKey, true);
// get tree map from parent
$remoteTree = Emergence::resolveCollectionFromParent($path);
if (!$remoteTree) {
return 0;
}
$filesResolved = 0;
$startTime = time();
foreach ($remoteTree['files'] as $remotePath => $remoteFile) {
$node = Site::resolvePath($remotePath);
if ($node && $node->Timestamp >= $startTime) {
$filesResolved++;
}
}
return $filesResolved;
}
示例2: setUrlToCache
protected function setUrlToCache()
{
$url = $this->findUrlFromDB();
$cache = new \Cache(['path' => __DIR__ . '/../runtime/redirectCache/', 'name' => 'default', 'extension' => '.cache']);
$cache->store($this->currentUrl, $url);
return $url;
}
示例3: stats
public static function stats()
{
$player = self::get_user_logged_in();
$url = $_SERVER['REQUEST_URI'];
$stripped_url = preg_replace("/[^A-Za-z0-9 ]/", '', $url);
if ($player) {
$stripped_url .= $player->playerid;
}
// Fetch page from cache
$cached_page = Cache::getPage($stripped_url);
if ($cached_page != null && Cache::on()) {
// Use cached page (which is up to date because outdated pages are deleted)
echo $cached_page;
} else {
// Make page from scratch
$high_scores = null;
if ($player) {
$high_scores = Game::player_high_scores($player->playerid);
}
$game_count = Game::count_all();
$throw_count = Score::count_all();
$latest_game = Game::latest_game();
$popular_courses = Course::popular_courses_all_players();
$page_html = View::make("stats/stats.html", array('game_count' => $game_count, 'throw_count' => $throw_count, 'latest_game' => $latest_game, 'popular_courses' => $popular_courses, 'player' => $player, 'high_scores' => $high_scores));
if (Cache::on()) {
// Don't include the page message in the cached file
$page_html = Cache::strip_tags_content($page_html, "message-success");
Cache::store($stripped_url, $page_html);
}
}
}
示例4: zbase_cache_driver
/**
* Return the current cache driver
* @return string
*/
function zbase_cache_driver($store = null)
{
if (is_null($store)) {
return \Cache::driver();
}
return \Cache::store($store);
}
示例5: osc_latestTweets
function osc_latestTweets($num = 5)
{
require_once osc_lib_path() . 'osclass/classes/Cache.php';
$cache = new Cache('admin-twitter', 900);
if ($cache->check()) {
return $cache->retrieve();
}
$list = array();
$content = osc_file_get_contents('https://twitter.com/statuses/user_timeline/osclass.rss');
if ($content) {
$xml = simplexml_load_string($content);
if (isset($xml->error)) {
return $list;
}
$count = 0;
foreach ($xml->channel->item as $item) {
$list[] = array('link' => strval($item->link), 'title' => strval($item->title), 'pubDate' => strval($item->pubDate));
$count++;
if ($count == $num) {
break;
}
}
}
$cache->store($list);
return $list;
}
示例6: __construct
public function __construct($id = null, $enable_hook = true)
{
$this->class_name = get_class($this);
if (!Object::$db) {
Object::$db = Db::getInstance();
}
self::$is_cache_enabled = defined('OBJECT_CACHE_ENABLE') ? OBJECT_CACHE_ENABLE : false;
if (isset($id) && Validate::isUnsignedId($id)) {
$cache_id = $this->class_name . self::CACHE_PREFIX_MODEL . (int) $id;
if (!Cache::isStored($cache_id)) {
$sql = new DbQuery();
$sql->from($this->def['table'], 'a');
$sql->where('a.' . $this->def['primary'] . '=' . (int) $id);
if ($object_datas = Object::$db->getRow($sql)) {
Cache::store($cache_id, $object_datas);
}
} else {
$object_datas = Cache::retrieve($cache_id);
}
if ($object_datas) {
$this->id = (int) $id;
foreach ($object_datas as $key => $value) {
if (array_key_exists($key, $this)) {
$this->{$key} = $value;
}
}
}
if ($enable_hook && method_exists($this, 'extraConstruct')) {
$this->extraConstruct();
}
}
}
示例7: render
function render($cachename = false)
{
$out = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="sv" lang="sv">
<head><title>Kyrkorna i Linköping</title>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<meta name="description" content="startsida" />
<link href="style.css" type="text/css" rel="stylesheet" />
</head><body><h1>Linköpings kyrkor</h1>Välkommen till denna sida för att se vad som händer i Linköpings kyrkor. Om du saknar nån kyrka, eller ser något som inte funkar, skicka ett mail till min gmail, "jonatan.olofsson" at.. osv. (@gmail.com).<br \\>För den intresserade finns källkod på <a href="http://github.com/jonatanolofsson/heisasolidbase">github</a>';
$meetings = array();
foreach ($this->churches as $church) {
$meetings = array_merge($meetings, self::get_all($church));
}
usort($meetings, array('UI', 'sorting'));
$start = time() - 60 * 60;
$newday = true;
$newmonth = true;
$lastday = false;
$lastmonth = false;
foreach ($meetings as $meeting) {
if ($meeting['when'] < $start) {
continue;
}
if (date('Ym', $meeting['when']) != $lastmonth) {
if ($lastmonth != false) {
$out .= '</div>';
}
$out .= '<div class="month"><h2>' . strftime('%B', $meeting['when']) . '</h2>';
$lastmonth = date('Ym', $meeting['when']);
}
if (date('Ymd', $meeting['when']) != $lastday) {
if ($lastday != false) {
$out .= '</ul></div>';
}
$out .= '<div class="day"><h3>' . strftime('%a, %e', $meeting['when']) . '</h3><ul class="meetings">';
$lastday = date('Ymd', $meeting['when']);
}
$out .= '<li class="meeting">' . strftime('%H:%M', $meeting['when']) . ' - ' . $meeting['what'];
$out .= '<a href="' . $meeting['church']['url'] . '" class="church">' . $meeting['church']['name'] . '</a>';
if ($meeting['info'] || $meeting['where']) {
$out .= '<div class="info">';
if ($meeting['where']) {
$out .= '<span class="where">' . strip_tags($meeting['where'], '<p><a><b><em>') . '</span>';
}
if ($meeting['info']) {
$out .= strip_tags($meeting['info'], '<p><a><b><em>');
}
$out .= '</div>';
}
//if($meeting['extra']) $out .= '<div class="extra">'.$meeting['extra'].'</div>';
$out .= '</li>';
}
$out .= '</div></div></body></html>';
if ($cachename) {
Cache::store($cachename, $out);
}
print $out;
}
示例8: load
/**
* Load ObjectModel
* @param $id
* @param $id_lang
* @param $entity ObjectModel
* @param $entity_defs
* @param $id_shop
* @param $should_cache_objects
* @throws PrestaShopDatabaseException
*/
public function load($id, $id_lang, $entity, $entity_defs, $id_shop, $should_cache_objects)
{
// Load object from database if object id is present
$cache_id = 'objectmodel_' . $entity_defs['classname'] . '_' . (int) $id . '_' . (int) $id_shop . '_' . (int) $id_lang;
if (!$should_cache_objects || !Cache::isStored($cache_id)) {
$sql = new DbQuery();
$sql->from($entity_defs['table'], 'a');
$sql->where('a.`' . bqSQL($entity_defs['primary']) . '` = ' . (int) $id);
// Get lang informations
if ($id_lang && isset($entity_defs['multilang']) && $entity_defs['multilang']) {
$sql->leftJoin($entity_defs['table'] . '_lang', 'b', 'a.`' . bqSQL($entity_defs['primary']) . '` = b.`' . bqSQL($entity_defs['primary']) . '` AND b.`id_lang` = ' . (int) $id_lang);
if ($id_shop && !empty($entity_defs['multilang_shop'])) {
$sql->where('b.`id_shop` = ' . (int) $id_shop);
}
}
// Get shop informations
if (Shop::isTableAssociated($entity_defs['table'])) {
$sql->leftJoin($entity_defs['table'] . '_shop', 'c', 'a.`' . bqSQL($entity_defs['primary']) . '` = c.`' . bqSQL($entity_defs['primary']) . '` AND c.`id_shop` = ' . (int) $id_shop);
}
if ($object_datas = Db::getInstance()->getRow($sql)) {
if (!$id_lang && isset($entity_defs['multilang']) && $entity_defs['multilang']) {
$sql = 'SELECT *
FROM `' . bqSQL(_DB_PREFIX_ . $entity_defs['table']) . '_lang`
WHERE `' . bqSQL($entity_defs['primary']) . '` = ' . (int) $id . ($id_shop && $entity->isLangMultishop() ? ' AND `id_shop` = ' . (int) $id_shop : '');
if ($object_datas_lang = Db::getInstance()->executeS($sql)) {
foreach ($object_datas_lang as $row) {
foreach ($row as $key => $value) {
if ($key != $entity_defs['primary'] && array_key_exists($key, $entity)) {
if (!isset($object_datas[$key]) || !is_array($object_datas[$key])) {
$object_datas[$key] = array();
}
$object_datas[$key][$row['id_lang']] = $value;
}
}
}
}
}
$entity->id = (int) $id;
foreach ($object_datas as $key => $value) {
if (array_key_exists($key, $entity)) {
$entity->{$key} = $value;
} else {
unset($object_datas[$key]);
}
}
if ($should_cache_objects) {
Cache::store($cache_id, $object_datas);
}
}
} else {
$object_datas = Cache::retrieve($cache_id);
if ($object_datas) {
$entity->id = (int) $id;
foreach ($object_datas as $key => $value) {
$entity->{$key} = $value;
}
}
}
}
示例9: getURLContents
/**
*
*/
protected function getURLContents()
{
if (isset($this->cache) && !$this->refresh) {
$contents = $this->cache->load('URLContents', $loaded);
if ($loaded) {
return $contents;
}
}
$contents = $this->request->init()->process();
if ($contents === FALSE) {
throw new Exception('URL konnte nicht gelesen werden: ' . Code::varInfo($this->request->getURL()));
}
if (isset($this->cache)) {
$this->cache->store('URLContents', $contents);
}
return $contents;
}
示例10: getBrowserInfoFromAgent
public function getBrowserInfoFromAgent($browscap, $agent)
{
if (Cache::store('redis')->has($agent)) {
return json_decode(Cache::store('redis')->get($agent), true);
}
$browser_info = json_encode($browscap->getBrowser($agent));
//dd($browser_info);
Cache::store('redis')->put($agent, $browser_info, 10);
return json_decode($browser_info, true);
}
示例11: __construct
public function __construct($filter, $start, $count)
{
$cache = new Cache('note_list', false);
if (!($metaList = $cache->fetch(compact('filter', 'start', 'count')))) {
$metaList = Evernote::_noteStore()->findNotesMetadata(AUTH_TOKEN, $filter, $start, $count, new EDAM\NoteStore\NotesMetadataResultSpec());
$cache->store($metaList);
}
$this->_metaList = $metaList;
$this->total = $metaList->totalNotes;
}
示例12: isTaxInUse
/**
* @param int $id_tax
* @return bool
*/
public static function isTaxInUse($id_tax)
{
$cache_id = 'TaxRule::isTaxInUse_' . (int) $id_tax;
if (!Cache::isStored($cache_id)) {
$result = (int) Db::getInstance()->getValue('SELECT COUNT(*) FROM `' . _DB_PREFIX_ . 'tax_rule` WHERE `id_tax` = ' . (int) $id_tax);
Cache::store($cache_id, $result);
return $result;
}
return Cache::retrieve($cache_id);
}
示例13: ps_cli_init_admin_context
public static function ps_cli_init_admin_context()
{
$context = Context::getContext();
// todo: load admin list and pick from it instead of assuming there's a user '1
$context->employee = new Employee(PS_CLI_EMPLOYEE::get_any_superadmin_id());
// some controllers die with fatal error if not set
Cache::store('isLoggedBack' . $context->employee->id, true);
$context->shop = new Shop(Configuration::get('PS_SHOP_DEFAULT'));
// load a generic front controller by default
$context->controller = new FrontController();
}
示例14: load
public function load($token)
{
if (!empty($token)) {
$cache = new Cache('user');
if (!($user = $cache->fetch($token))) {
$user = self::_userStore()->getUser($token);
$cache->store($user);
}
$this->user = $user;
}
return $this;
}
示例15: load
public function load($guid)
{
if (!empty($guid)) {
$cache = new Cache('notebook');
if (!($notebook = $cache->fetch($guid))) {
$notebook = self::_noteStore()->getNotebook(AUTH_TOKEN, $guid);
$cache->store($notebook);
}
$this->notebook = $notebook;
}
return $this;
}