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


PHP Cache函数代码示例

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


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

示例1: toArray

 /**
  * @param array $fields
  * @param array $expand
  * @param bool $recursive
  * @return mixed
  */
 public function toArray(array $fields = [], array $expand = [], $recursive = true)
 {
     $hash = [serialize($this->primaryKey), serialize($fields), serialize($expand), serialize($recursive), $this->getAttributesHash()];
     $key = sprintf('active-record-%s-%s', get_called_class(), sha1(implode('|', $hash)));
     $data = Cache()->get($key);
     if (empty($data)) {
         $data = parent::toArray($fields, $expand, $recursive);
         Cache()->set($key, $data, 3600);
     }
     return $data;
 }
开发者ID:cookyii,项目名称:base,代码行数:17,代码来源:CacheArrayableTrait.php

示例2: init

 /**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     if (isset($_GET['clear'])) {
         Cache()->flush();
         Cache('authManager')->flush();
         Cache('schema')->flush();
         Cache('query')->flush();
         if (function_exists('opcache_reset')) {
             opcache_reset();
         }
     }
 }
开发者ID:cookyii,项目名称:base,代码行数:16,代码来源:Controller.php

示例3: testMain

 public function testMain()
 {
     ob_start();
     dump(['test' => rand()]);
     // это тест!
     expect('Функция дампа не отдает результат', ob_get_clean())->notEmpty();
     $this->assertInstanceOf(yii\log\Dispatcher::class, YiiLog());
     $this->assertInstanceOf(yii\db\Connection::class, DB());
     $this->assertInstanceOf(yii\base\ErrorHandler::class, ErrorHandler());
     $this->assertInstanceOf(yii\caching\Cache::class, Cache());
     $this->assertInstanceOf(yii\i18n\Formatter::class, Formatter());
     $this->assertInstanceOf(yii\base\View::class, View());
     $this->assertInstanceOf(yii\i18n\I18N::class, I18N());
     $this->assertInstanceOf(yii\rbac\ManagerInterface::class, AuthManager());
     $this->assertInstanceOf(yii\web\AssetManager::class, AssetManager());
     $this->assertInstanceOf(yii\web\User::class, User());
     $this->assertInstanceOf(yii\base\Request::class, Request());
     $this->assertInstanceOf(yii\base\Response::class, Response());
     $this->assertInstanceOf(yii\web\Session::class, Session());
     $this->assertInstanceOf(yii\web\UrlManager::class, UrlManager());
     $this->assertInstanceOf(yii\mail\MailerInterface::class, Mailer());
     $this->assertInstanceOf(services\File\Service::class, FileService());
     $this->assertInstanceOf(services\Activity\Service::class, ActivityService());
 }
开发者ID:rmrevin,项目名称:yii2-application,代码行数:24,代码来源:GlobalsFunctionsTest.php

示例4: glob

<?php

include_once 'security.php';
include_once 'config.php';
$name_index = 0;
if (isset($_GET['cache']) == true && $_GET['cache'] == 1) {
    //Find addon files
    $addlist = glob($addon_dir . '/*' . $addon_suffix);
    //foreach(glob('*_addon.php') as $fname){
    for ($i = 0; $i < count($addlist); $i++) {
        //echo $addlist[$i];
        CacheAddon($addlist[$i]);
        $name_index++;
    }
    Cache();
}
//$current_page="test_addon.php"; //temp...
if (isset($_GET['LID']) == true) {
    include 'temp_argument.php';
    //print_r($test1);
}
LID_Init();
include_once "cache/addon_tables.php";
$niche_action = 'current';
if (isset($_GET['page']) == true) {
    $current_page = $_GET['page'];
    //include "$current_page"; //do this in theme...
} else {
    $current_page = "blank.php";
}
include_once $theme_file;
开发者ID:Earlz,项目名称:ancientstuff,代码行数:31,代码来源:index.php

示例5: save

 /**
  * Saves an element instance to a parent
  *
  */
 function save()
 {
     $id_element = $this->input->post('id_element');
     $parent = $this->input->post('parent');
     $id_parent = $this->input->post('id_parent');
     if (!empty($parent) && !empty($id_parent)) {
         // Clear the cache
         Cache()->clear_cache();
         $id_element_definition = $this->input->post('id_element_definition');
         // Save Element and extend fields
         $id_element = $this->element_model->save($parent, $id_parent, $id_element, $id_element_definition, $_POST);
         // Get Elements
         $this->callback = array(array('fn' => 'ION.updateContentTabs', 'args' => array($parent, $id_parent)));
         // Answer
         $this->success(lang('ionize_message_content_element_saved'), array('id_element' => $id_element));
     } else {
         $this->callback = array(array('fn' => 'ION.notification', 'args' => array('error', lang('ionize_message_element_cannot_be_added_to_parent'))));
     }
     $this->response();
 }
开发者ID:trk,项目名称:ionize,代码行数:24,代码来源:element.php

示例6: set_cache

 /**
  * Cache or returns one tag cache
  *
  *
  */
 public static function set_cache($tag, $output)
 {
     if (isset($tag->attr['nocache'])) {
         return FALSE;
     }
     $id = self::get_tag_cache_id($tag);
     Cache()->store($id, $output);
 }
开发者ID:BGCX261,项目名称:zillatek-project-svn-to-git,代码行数:13,代码来源:Tagmanager.php

示例7: save

 /**
  * Saves one media metadata
  *
  */
 public function save()
 {
     // Clear the cache
     Cache()->clear_cache();
     // Standard data;
     $data = array();
     // Standard fields
     $fields = $this->db->list_fields('media');
     foreach ($fields as $field) {
         if ($this->input->post($field) !== FALSE) {
             $data[$field] = htmlentities($this->input->post($field), ENT_QUOTES, 'utf-8');
         }
     }
     // Lang data
     $lang_data = array();
     $fields = $this->db->list_fields('media_lang');
     foreach (Settings::get_languages() as $language) {
         foreach ($fields as $field) {
             if ($this->input->post($field . '_' . $language['lang']) !== FALSE) {
                 $lang_data[$language['lang']][$field] = htmlentities($this->input->post($field . '_' . $language['lang']), ENT_QUOTES, 'utf-8');
             }
         }
     }
     // Event
     $event_data = array('base' => $data, 'lang' => $lang_data);
     $event_received = Event::fire('Media.save.before', $event_data);
     $event_received = array_pop($event_received);
     if (!empty($event_received['base']) && !empty($event_received['lang'])) {
         $data = $event_received['base'];
         $lang_data = $event_received['lang'];
     }
     // Database save
     $id_media = $this->media_model->save($data, $lang_data);
     // Event
     $event_data = array('base' => $data, 'lang' => $lang_data);
     Event::fire('Media.save.success', $event_data);
     // Save extend fields data
     $this->extend_field_model->save_data('media', $id_media, $_POST);
     // Save parent context data
     $this->media_model->save_context_data($_POST);
     $media = $this->media_model->get($id_media, Settings::get_lang('default'));
     // Delete picture thumbnails
     if ($media['type'] == 'picture') {
         $this->medias->delete_thumbs($media);
     }
     if ($id_media !== FALSE) {
         // Success Message
         $this->callback = array(array('fn' => 'mediaManager.loadMediaList', 'args' => $media['type']), array('fn' => 'ION.notification', 'args' => array('success', lang('ionize_message_media_data_saved'))));
     } else {
         Event::fire('Media.save.error');
         // Error Message
         $this->callback[] = array('fn' => 'ION.notification', 'args' => array('error', lang('ionize_message_media_data_not_saved')));
     }
     $this->response();
 }
开发者ID:pompalini,项目名称:emngo,代码行数:59,代码来源:media.php

示例8: delete

 /**
  * Deletes one page
  * @note	For the moment, this method doesn't delete the linked articles, which will stay in database as phantom
  * @param	int		$id_page
  *
  */
 public function delete($id_page)
 {
     $affected_rows = $this->page_model->delete($id_page);
     // Delete was successful
     if ($affected_rows > 0) {
         // Clean URL table
         $this->url_model->clean_table();
         // Clear the cache
         Cache()->clear_cache();
         // Remove deleted article from DOM
         $this->callback[] = array('fn' => 'ION.deleteDomElements', 'args' => array('.page' . $id_page));
         // If the current edited article is deleted
         if ($this->input->post('redirect')) {
             $this->callback[] = array('fn' => 'ION.updateElement', 'args' => array('element' => 'mainPanel', 'url' => 'dashboard'));
         }
         $this->success(lang('ionize_message_operation_ok'));
     } else {
         $this->error(lang('ionize_message_operation_nok'));
     }
 }
开发者ID:trk,项目名称:ionize,代码行数:26,代码来源:page.php

示例9: set_cache

 /**
  * Cache or returns one tag cache
  *
  * @param	FTL_Binding		tag
  * @param	String
  *
  * @return	boolean / void
  *
  */
 public static function set_cache(FTL_Binding $tag, $output)
 {
     $cache = $tag->getAttribute('cache', TRUE);
     if (!$cache) {
         return FALSE;
     }
     $id = self::get_tag_cache_id($tag);
     Cache()->store($id, $output);
 }
开发者ID:pompalini,项目名称:emngo,代码行数:18,代码来源:Tagmanager.php

示例10: save_module_translations

 function save_module_translations()
 {
     // Clear the cache
     Cache()->clear_cache();
     $module = $this->input->post('module');
     foreach (Settings::get_languages() as $language) {
         $lang = $language['lang'];
         // Creates the lang folder if it doesn't exists
         $path = FCPATH . 'themes/' . Settings::get('theme') . '/language/' . $lang;
         if (!is_dir($path)) {
             try {
                 @mkdir($path, 0777, TRUE);
             } catch (Exception $e) {
                 $this->error(lang('ionize_message_language_dir_creation_fail'));
             }
         }
         // Build the file data
         $data = "<?php\n\n";
         foreach ($_REQUEST as $key => $value) {
             if (substr($key, 0, 3) == 'key') {
                 $idx = substr($key, 4);
                 $term = $_REQUEST[$key];
                 if ($term != '') {
                     $value = $_REQUEST[str_replace(' ', '_', 'value_' . $lang . '_' . $idx)];
                     if (!get_magic_quotes_gpc()) {
                         $value = addslashes($value);
                     }
                     $value = str_replace("\\'", "'", $value);
                     $data .= "\$lang['" . $term . "'] = \"" . $value . "\";\n";
                 }
             }
         }
         // Finish the file data
         $data .= "\n" . '?' . '>';
         // Try writing the language file
         try {
             write_file($path . '/' . Settings::get('theme') . '_lang.php', $data);
         } catch (Exception $e) {
             $this->error(lang('ionize_message_language_file_creation_fail'));
         }
     }
     $this->update[] = array('element' => 'mainPanel', 'url' => admin_url() . 'translation', 'title' => lang('ionize_title_translation'));
     // If method arrives here, everything was OK
     $this->success(lang('ionize_message_language_files_saved'));
 }
开发者ID:BGCX261,项目名称:zillatek-project-svn-to-git,代码行数:45,代码来源:translation.php

示例11: save

 /**
  * Saves one media metadata
  *
  */
 function save()
 {
     // Clear the cache
     Cache()->clear_cache();
     // Get old values
     $id_media = $this->input->post('id_media');
     $old_media_data = $this->media_model->get($id_media);
     // Standard data;
     $data = array();
     // Standard fields
     $fields = $this->db->list_fields('media');
     foreach ($fields as $field) {
         if ($this->input->post($field) !== false) {
             $data[$field] = $this->input->post($field);
         }
     }
     // Lang data
     $lang_data = array();
     $fields = $this->db->list_fields('media_lang');
     foreach (Settings::get_languages() as $language) {
         foreach ($fields as $field) {
             if ($this->input->post($field . '_' . $language['lang']) !== false) {
                 $lang_data[$language['lang']][$field] = $this->input->post($field . '_' . $language['lang']);
             }
         }
     }
     // Database save
     $this->id = $this->media_model->save($data, $lang_data);
     // Save extend fields data
     $this->extend_field_model->save_data('media', $this->id, $_POST);
     $media = $this->media_model->get($this->id, Settings::get_lang('default'));
     // Save ID3 to file if MP3
     if ($this->is($media['path'], 'mp3')) {
         $tags = array('artist' => array($media['copyright']), 'title' => array($media['title']), 'album' => array($media['container']));
         $date = strtotime($media['date']);
         if ($date !== FALSE) {
             $tags['year'][] = (string) date('Y', $date);
         }
         $this->write_ID3($media['path'], $tags);
     }
     // delete picture squares if square_crop is changed
     if ($media['type'] == 'picture' && $media['square_crop'] != $old_media_data['square_crop']) {
         $this->load->library('medias');
         $this->medias->delete_squares($media);
     }
     if ($this->id !== false) {
         $this->success(lang('ionize_message_media_data_saved'));
     } else {
         $this->success(lang('ionize_message_media_data_not_saved'));
     }
 }
开发者ID:nbourguig,项目名称:ionize,代码行数:55,代码来源:media.php

示例12: clear_cache

 function clear_cache()
 {
     Cache()->clear_cache();
     // Answer
     $this->success(lang('ionize_message_cache_cleared'));
 }
开发者ID:nbourguig,项目名称:ionize,代码行数:6,代码来源:setting.php

示例13: save

 /**
  * Saves the translation language files
  *
  */
 function save()
 {
     // Clear the cache
     Cache()->clear_cache();
     // URL helper
     $this->load->helper('url');
     $filename = $this->input->post('filename');
     $path = $this->input->post('path');
     $lang_path = $this->input->post('lang_path');
     $type = $this->input->post('type');
     $error = FALSE;
     foreach (Settings::get_languages() as $language) {
         $lang = $language['lang'];
         // Creates the lang folder if it doesn't exists
         $path = $lang_path . $lang;
         if (!is_dir($path)) {
             try {
                 @mkdir($path, 0777, TRUE);
             } catch (Exception $e) {
                 $this->error(lang('ionize_message_language_dir_creation_fail'));
             }
         }
         // Build the file data
         $data = "<?php\n\n";
         foreach ($_REQUEST as $key => $value) {
             if (substr($key, 0, 3) == 'key') {
                 $idx = substr($key, 4);
                 $term = url_title($_REQUEST[$key], 'underscore');
                 if ($term != '') {
                     $value = $_REQUEST[str_replace(' ', '_', 'value_' . $lang . '_' . $idx)];
                     $value = stripslashes($value);
                     if (!get_magic_quotes_gpc()) {
                         $value = addslashes($value);
                     }
                     $value = str_replace("\\'", "'", $value);
                     $value = str_replace("'", "\\'", $value);
                     $data .= "\$lang['" . $term . "'] = '" . $value . "';\n";
                 }
             }
         }
         // Finish the file data
         $data .= "\n" . '?' . '>';
         // Try writing the language file
         $file = $path . $this->DP . $filename;
         if (!file_exists($file)) {
             write_file($file, $data);
         }
         if (!is_really_writable($file)) {
             $this->error(lang('ionize_message_message_no_write_rights') . ' : ' . $file);
             $error = TRUE;
         } else {
             write_file($file, $data);
         }
     }
     if (!$error) {
         $this->callback = array(array('fn' => 'ION.HTML', 'args' => array('translation/edit', array('type' => $type, 'filename' => $filename, 'path' => $path, 'lang_path' => $lang_path), array('update' => 'splitPanel_mainPanel_pad'))));
         $this->success(lang('ionize_message_language_files_saved'));
     }
 }
开发者ID:trk,项目名称:ionize,代码行数:63,代码来源:translation.php

示例14: declarer_url_arbo

/**
 * Retrouver/Calculer l'ensemble des segments d'url d'un objet
 *
 * http://doc.spip.org/@declarer_url_arbo
 *
 * @param string $type
 * @param int $id_objet
 * @return string
 */
function declarer_url_arbo($type, $id_objet)
{
    static $urls = array();
    // utiliser un cache memoire pour aller plus vite
    if (!is_null($C = Cache())) {
        return $C;
    }
    // Se contenter de cette URL si elle existe ;
    // sauf si on invoque par "voir en ligne" avec droit de modifier l'url
    // l'autorisation est verifiee apres avoir calcule la nouvelle url propre
    // car si elle ne change pas, cela ne sert a rien de verifier les autorisations
    // qui requetent en base
    $modifier_url = (defined('_VAR_URLS') and _VAR_URLS);
    if (!isset($urls[$type][$id_objet]) or $modifier_url) {
        $r = renseigner_url_arbo($type, $id_objet);
        // Quand $type ne reference pas une table
        if ($r === false) {
            return false;
        }
        if (!is_null($r)) {
            $urls[$type][$id_objet] = $r;
        }
    }
    if (!isset($urls[$type][$id_objet])) {
        return "";
    }
    # objet inexistant
    $url_propre = $urls[$type][$id_objet]['url'];
    // si on a trouve l'url
    // et que le parent est bon
    // et (permanente ou pas de demande de modif)
    if (!is_null($url_propre) and $urls[$type][$id_objet]['id_parent'] == $urls[$type][$id_objet]['parent'] and ($urls[$type][$id_objet]['perma'] or !$modifier_url)) {
        return declarer_url_arbo_rec($url_propre, $type, isset($urls[$type][$id_objet]['parent']) ? $urls[$type][$id_objet]['parent'] : 0, isset($urls[$type][$id_objet]['type_parent']) ? $urls[$type][$id_objet]['type_parent'] : null);
    }
    // Si URL inconnue ou maj forcee sur une url non permanente, recreer une url
    $url = $url_propre;
    if (is_null($url_propre) or $modifier_url and !$urls[$type][$id_objet]['perma']) {
        $url = pipeline('arbo_creer_chaine_url', array('data' => $url_propre, 'objet' => array_merge($urls[$type][$id_objet], array('type' => $type, 'id_objet' => $id_objet))));
        // Eviter de tamponner les URLs a l'ancienne (cas d'un article
        // intitule "auteur2")
        include_spip('inc/urls');
        $objets = urls_liste_objets();
        if (preg_match(',^(' . $objets . ')[0-9]*$,', $url, $r) and $r[1] != $type) {
            $url = $url . _url_arbo_sep_id . $id_objet;
        }
    }
    // Pas de changement d'url ni de parent
    if ($url == $url_propre and $urls[$type][$id_objet]['id_parent'] == $urls[$type][$id_objet]['parent']) {
        return declarer_url_arbo_rec($url_propre, $type, $urls[$type][$id_objet]['parent'], $urls[$type][$id_objet]['type_parent']);
    }
    // verifier l'autorisation, maintenant qu'on est sur qu'on va agir
    if ($modifier_url) {
        include_spip('inc/autoriser');
        $modifier_url = autoriser('modifierurl', $type, $id_objet);
    }
    // Verifier si l'utilisateur veut effectivement changer l'URL
    if ($modifier_url and CONFIRMER_MODIFIER_URL and $url_propre and $url != preg_replace('/' . preg_quote(_url_propres_sep_id, '/') . '.*/', '', $url_propre)) {
        $confirmer = true;
    } else {
        $confirmer = false;
    }
    if ($confirmer and !_request('ok')) {
        die("vous changez d'url ? {$url_propre} -&gt; {$url}");
    }
    $set = array('url' => $url, 'type' => $type, 'id_objet' => $id_objet, 'id_parent' => $urls[$type][$id_objet]['parent'], 'perma' => intval($urls[$type][$id_objet]['perma']));
    include_spip('action/editer_url');
    if (url_insert($set, $confirmer, _url_arbo_sep_id)) {
        $urls[$type][$id_objet]['url'] = $set['url'];
        $urls[$type][$id_objet]['id_parent'] = $set['id_parent'];
    } else {
        // l'insertion a echoue,
        //serveur out ? retourner au mieux
        $urls[$type][$id_objet]['url'] = $url_propre;
    }
    return declarer_url_arbo_rec($urls[$type][$id_objet]['url'], $type, $urls[$type][$id_objet]['parent'], $urls[$type][$id_objet]['type_parent']);
}
开发者ID:loorenzooo,项目名称:aslfc,代码行数:85,代码来源:arbo.php


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