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


PHP Cache::write方法代码示例

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


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

示例1: afterLayout

 function afterLayout()
 {
     if (Configure::read('Cache.disable') || Configure::read('ViewMemcache.disable')) {
         return true;
     }
     try {
         if (!empty($this->_View->viewVars['enableViewMemcache'])) {
             if (isset($this->_View->viewVars['viewMemcacheDuration'])) {
                 // CakeLog::write('debug', "ViewMemCache: duration override: {$this->_View->viewVars['viewMemcacheDuration']}");
                 @Cache::set(array('duration' => $this->_View->viewVars['viewMemcacheDuration'], null, 'view_memcache'));
                 //'+30 days' or seconds
             }
             if (!isset($this->_View->viewVars['viewMemcacheNoFooter'])) {
                 //CakeLog::write('debug', "ViewMemCache: footer disabled");
                 $this->cacheFooter = "\n<!-- ViewCached";
                 if ($this->gzipContent) {
                     $this->cacheFooter .= ' gzipped';
                 }
                 $this->cacheFooter .= ' ' . date('r') . ' -->';
             }
             if ($this->gzipContent && empty($this->_View->viewVars['viewMemcacheDisableGzip'])) {
                 //CakeLog::write('debug', "ViewMemCache: gzipping ".$this->request->here."\n\n".var_export($this->request,true)."\n\n".var_export($_SERVER,true));
                 @Cache::write($this->request->here, gzencode($this->_View->output . $this->cacheFooter, $this->compressLevel), 'view_memcache');
             } else {
                 //CakeLog::write('debug', "ViewMemCache: NOT gzipping ");
                 @Cache::write($this->request->here, $this->_View->output . $this->cacheFooter, 'view_memcache');
             }
         }
     } catch (Exception $e) {
         //do nothing
     }
     return true;
 }
开发者ID:Jpsstack,项目名称:cakephp-viewmemcache,代码行数:33,代码来源:ViewMemcacheHelper.php

示例2: _read

 protected function _read()
 {
     $settingsFile = CONFIGS . DS . 'settings.php';
     include $settingsFile;
     if (!isset($settings)) {
         trigger_error(sprintf(__('Missing settings file[%s] or $settings could not be found', true), $settingsFile));
         return array();
     }
     $records = $this->find('all');
     foreach ($records as $record) {
         switch ($record['Setting']['name']) {
             case 'per_page_options':
                 $settings[$record['Setting']['name']] = explode(',', $record['Setting']['value']);
                 break;
             case 'issue_list_default_columns':
                 $settings[$record['Setting']['name']] = Spyc::YAMLLoad($record['Setting']['value']);
                 // array_slice(array_map('trim',explode('- ',$v['Setting']['value'])),1);
                 break;
             default:
                 $settings[$record['Setting']['name']] = $record['Setting']['value'];
         }
     }
     Cache::write(self::$__cacheKey, $settings);
     return $settings;
 }
开发者ID:hiromi2424,项目名称:candycane_clone,代码行数:25,代码来源:setting.php

示例3: smarty_function_language_box

function smarty_function_language_box($params, $template)
{
    // Cache the output.
    $cache_name = 'vam_language_box_output' . (isset($params['template']) ? '_' . $params['template'] : '') . '_' . $_SESSION['Customer']['language_id'];
    $language_box_output = Cache::read($cache_name);
    if ($language_box_output === false) {
        ob_start();
        global $content;
        App::import('Component', 'Smarty');
        $Smarty =& new SmartyComponent();
        App::import('Model', 'Language');
        $Language =& new Language();
        $languages = $Language->find('all', array('conditions' => array('active' => '1')));
        if (count($languages) == 1) {
            return;
        }
        $keyed_languages = array();
        foreach ($languages as $language) {
            $language['Language']['url'] = BASE . '/languages/pick_language/' . $language['Language']['id'];
            $language['Language']['image'] = BASE . '/img/flags/' . $language['Language']['iso_code_2'] . '.png';
            $keyed_languages[] = $language['Language'];
        }
        $vars = array('languages' => $keyed_languages);
        $display_template = $Smarty->load_template($params, 'language_box');
        $Smarty->display($display_template, $vars);
        // Write the output to cache and echo them
        $language_box_output = @ob_get_contents();
        ob_end_clean();
        Cache::write($cache_name, $language_box_output);
    }
    echo $language_box_output;
}
开发者ID:risnandar,项目名称:testing,代码行数:32,代码来源:function.language_box.php

示例4: admin_index

 /**
  * admin_index
  *
  * @param id integer aco id, when null, the root ACO is used
  * @return void
  */
 public function admin_index($id = null, $level = null)
 {
     $this->set('title_for_layout', __('Permissions'));
     if ($id == null) {
         $root = $this->AclAco->node('controllers');
         $root = $root[0];
     } else {
         $root = $this->AclAco->read(null, $id);
     }
     if ($level !== null) {
         $level++;
     }
     $acos = $this->AclAco->getChildren($root['Aco']['id']);
     $roles = $this->Role->find('list');
     $this->set(compact('acos', 'roles', 'level'));
     $aros = $this->AclAro->getRoles($roles);
     if ($this->RequestHandler->ext == 'json') {
         $options = array_intersect_key($this->request->query, array('perms' => null, 'urls' => null));
         $cacheName = 'permissions_aco_' . $root['Aco']['id'];
         $permissions = Cache::read($cacheName, 'permissions');
         if ($permissions === false) {
             $permissions = $this->AclPermission->format($acos, $aros, $options);
             Cache::write($cacheName, $permissions, 'permissions');
         }
     } else {
         $permissions = array();
     }
     $this->set(compact('aros', 'permissions'));
 }
开发者ID:laiello,项目名称:plankonindia,代码行数:35,代码来源:AclPermissionsController.php

示例5: beforeFilter

 public function beforeFilter()
 {
     $this->Auth->loginAction = array('controller' => 'users', 'action' => 'login', 'admin' => false);
     $this->Auth->loginRedirect = array('controller' => 'users', 'action' => 'index', 'admin' => true);
     $this->Auth->logoutRedirect = array('controller' => 'contents', 'action' => 'homepage', 'admin' => false, 'vendor' => false);
     $this->Auth->authorize = array('Controller');
     $this->Auth->authenticate = array(AuthComponent::ALL => array('userModel' => 'User', 'fields' => array('username' => 'username', 'password' => 'password'), 'scope' => array('User.active' => 1)), 'Form');
     if (isset($this->request->params['admin']) && $this->request->params['prefix'] == 'admin') {
         $this->set('authUser', $this->Auth->user());
         $this->layout = 'admin';
     } elseif (isset($this->request->params['vendor']) && $this->request->params['prefix'] == 'vendor') {
         $this->set('authUser', $this->Auth->user());
         $this->layout = 'vendor';
     } else {
         $this->Auth->allow();
         $menucategories = Cache::read('menucategories');
         if (!$menucategories) {
             $menucategories = ClassRegistry::init('Product')->find('all', array('recursive' => -1, 'contain' => array('User', 'Category'), 'fields' => array('Category.id', 'Category.name', 'Category.slug'), 'conditions' => array('User.active' => 1, 'Product.active' => 1, 'Product.category_id >' => 0, 'Category.id >' => 0), 'order' => array('Category.name' => 'ASC'), 'group' => array('Category.id')));
             Cache::set(array('duration' => '+10 minutes'));
             Cache::write('menucategories', $menucategories);
         }
         $this->set(compact('menucategories'));
         $menuvendors = Cache::read('menuvendors');
         if (!$menuvendors) {
             $menuvendors = ClassRegistry::init('User')->getVendors();
             Cache::set(array('duration' => '+10 minutes'));
             Cache::write('menuvendors', $menuvendors);
         }
         $this->set(compact('menuvendors'));
     }
     if ($this->RequestHandler->isAjax()) {
         $this->layout = 'ajax';
     }
     $this->AutoLogin->settings = array('model' => 'Member', 'username' => 'name', 'password' => 'pass', 'plugin' => '', 'controller' => 'members', 'loginAction' => 'signin', 'logoutAction' => 'signout', 'cookieName' => 'rememberMe', 'expires' => '+1 month', 'active' => true, 'redirect' => true, 'requirePrompt' => true);
 }
开发者ID:beyondkeysystem,项目名称:testone,代码行数:35,代码来源:AppController.php

示例6: testCache

 /**
  * testCache
  *
  */
 public function testCache()
 {
     $result = Cache::write('hoge', 'fuga');
     $this->assertTrue($result);
     $result = Cache::read('hoge');
     $this->assertIdentical($result, 'fuga');
 }
开发者ID:k1low,项目名称:setting,代码行数:11,代码来源:SystemControlTest.php

示例7: config

 function config()
 {
     $data = $this->find('all');
     $data = Set::combine($data, '{n}.Configurator.key', '{n}.Configurator.value');
     Cache::write('Config', $data);
     return $data;
 }
开发者ID:amerlini,项目名称:digigas-from-hg,代码行数:7,代码来源:configurator.php

示例8: _request

 protected function _request($path, $request = array())
 {
     // preparing request
     $request = Hash::merge($this->_request, $request);
     $request['uri']['path'] .= $path;
     // Read cached GET results
     if ($request['method'] == 'GET') {
         $cacheKey = $this->_generateCacheKey();
         $results = Cache::read($cacheKey);
         if ($results !== false) {
             return $results;
         }
     }
     // createding http socket object for later use
     $HttpSocket = new HttpSocket();
     // issuing request
     $response = $HttpSocket->request($request);
     // olny valid response is going to be parsed
     if (substr($response->code, 0, 1) != 2) {
         if (Configure::read('debugApis')) {
             debug($request);
             debug($response->body);
         }
         return false;
     }
     // parsing response
     $results = $this->_parseResponse($response);
     // cache and return results
     if ($request['method'] == 'GET') {
         Cache::write($cacheKey, $results);
     }
     return $results;
 }
开发者ID:kaburk,项目名称:CakePHP-Google,代码行数:33,代码来源:GoogleMapsApi.php

示例9: smarty_block_lang

function smarty_block_lang($params, $content, $template, &$repeat)
{
    if (is_null($content)) {
        return;
    }
    // Start caching
    $cache_name = 'vam_lang_' . $_SESSION['Customer']['language_id'] . '_' . $content;
    $output = Cache::read($cache_name);
    if ($output === false) {
        ob_start();
        App::import('Model', 'DefinedLanguage');
        $DefinedLanguage =& new DefinedLanguage();
        $language_content = $DefinedLanguage->find(array('language_id' => $_SESSION['Customer']['language_id'], 'key' => $content));
        if (empty($language_content['DefinedLanguage']['value'])) {
            //$output = "Error! Empty language value for: " . $content;
            $lang_output = $content;
        } else {
            $lang_output = $language_content['DefinedLanguage']['value'];
        }
        echo $lang_output;
        // End cache
        $output = @ob_get_contents();
        ob_end_clean();
        Cache::write($cache_name, $output);
    }
    echo $output;
}
开发者ID:risnandar,项目名称:testing,代码行数:27,代码来源:block.lang.php

示例10: GetRandomUser

 function GetRandomUser()
 {
     //SET GENERAL SETTINGS
     if (($settings = Cache::read('settings')) === false) {
         $SETTING = ClassRegistry::Init('Setting');
         $settings = $SETTING->find('first');
         Cache::write('settings', $settings);
     }
     $this->Cookie->domain = $settings['Setting']['site_domain'];
     $this->Cookie->path = "/";
     $cookie_rand = $this->Cookie->read('rand_user');
     $userlogin = $this->General->my_decrypt($this->Cookie->read('userlogin'));
     $RandomUser = ClassRegistry::Init("RandomUser");
     if (!is_null($cookie_rand)) {
         return $cookie_rand;
     } else {
         $ip = $_SERVER['REMOTE_ADDR'];
         //CHEK IP FIRST
         $cond = !is_null($userlogin) ? array("RandomUser.user_id" => $userlogin, "RandomUser.ip_address" => $ip) : array("RandomUser.ip_address " => $ip, 'RandomUser.user_id IS NULL');
         $find = $RandomUser->find("first", array('conditions' => $cond));
         if ($find == false) {
             $rand_user = $this->GenerateRandom();
             $this->Cookie->write('rand_user', $rand_user, false, 24 * 3600 * 30, $settings['Setting']['site_domain']);
             return $rand_user;
         } else {
             $rand_user = $find['RandomUser']['rand_id'];
             $this->Cookie->write('rand_user', $rand_user, false, 24 * 3600 * 30, $settings['Setting']['site_domain']);
             return $find['RandomUser']['rand_id'];
         }
     }
 }
开发者ID:koprals,项目名称:coda-gosales-hsbc,代码行数:31,代码来源:ActionComponent.php

示例11: startup

 /**
  * startup Called after beforeFilter
  * @return false
  */
 function startup()
 {
     $this->__initializeModel();
     if ($this->tableSupports('logout_field') && $this->Auth->user()) {
         if (!empty($this->Controller->data[$this->Auth->userModel]) && !$this->Auth->user($this->settings['logout_field'])) {
             Cache::delete('StayOutUser-' . $this->Auth->user($this->userModel->primaryKey), 'StayOutCache');
             $uuidhash = $this->generateHash();
             $this->userModel->id = $this->Auth->user($this->userModel->primaryKey);
             $this->userModel->saveField($this->settings['logout_field'], $uuidhash);
             $this->Session->write($this->Auth->sessionKey . '.' . $this->settings['logout_field'], $uuidhash);
         }
         if ($this->Auth->user()) {
             //Rewrite session with Auth incase session is lost and an Auto Login script starts up
             if ($this->Auth->user($this->settings['logout_field'])) {
                 $this->Session->write($this->Auth->sessionKey . '.' . $this->settings['logout_field'], $this->Auth->user($this->settings['logout_field']));
             }
             if ($this->settings['cache'] === true) {
                 $loggedOut = Cache::read('StayOutUser-' . $this->Auth->user($this->userModel->primaryKey), 'StayOutCache');
             }
             if (empty($loggedOut)) {
                 $loggedOut = $this->userModel->find('first', array('fields' => array($this->userModel->primaryKey), 'conditions' => array($this->userModel->primaryKey => $this->Auth->user($this->userModel->primaryKey), $this->settings['logout_field'] => $this->Session->read($this->Auth->sessionKey . '.' . $this->settings['logout_field'])), 'recursive' => -1));
                 if ($this->settings['cache'] === true) {
                     Cache::write('StayOutUser-' . $this->Auth->user($this->userModel->primaryKey), $loggedOut, 'StayOutCache');
                 }
             }
             if (empty($loggedOut)) {
                 $this->logout();
             }
         }
     }
 }
开发者ID:voidet,项目名称:stay_out,代码行数:35,代码来源:StayOutComponent.php

示例12: write

 public function write($id, $data)
 {
     if (!empty($this->cacheKey)) {
         Cache::write($id, $data, $this->cacheKey);
     }
     return parent::write($id, $data);
 }
开发者ID:nilBora,项目名称:konstruktor,代码行数:7,代码来源:ComboSession.php

示例13: smarty_function_currency_box

function smarty_function_currency_box($params, $template)
{
    // Cache the output.
    $cache_name = 'vam_currency_output' . (isset($params['template']) ? '_' . $params['template'] : '') . '_' . $_SESSION['Customer']['language_id'] . '_' . $_SESSION['Customer']['currency_id'];
    $currency_output = Cache::read($cache_name);
    if ($currency_output === false) {
        ob_start();
        App::import('Component', 'Smarty');
        $Smarty =& new SmartyComponent();
        App::import('Model', 'Currency');
        $Currency =& new Currency();
        $currencies = $Currency->find('all', array('conditions' => array('active' => '1')));
        if (count($currencies) == 1) {
            return;
        }
        $keyed_currencies = array();
        foreach ($currencies as $currency) {
            $keyed_currencies[] = $currency['Currency'];
        }
        $vars = array('currencies' => $keyed_currencies, 'currency_form_action' => BASE . '/currencies/pick_currency/');
        $display_template = $Smarty->load_template($params, 'currency_box');
        $Smarty->display($display_template, $vars);
        // Write the output to cache and echo them
        $currency_output = @ob_get_contents();
        ob_end_clean();
        Cache::write($cache_name, $currency_output);
    }
    echo $currency_output;
}
开发者ID:risnandar,项目名称:testing,代码行数:29,代码来源:function.currency_box.php

示例14: ical

 public function ical($params)
 {
     $this->setView('ical.php');
     $official = isset($params['official']);
     $group_name = isset($params['group']) ? $params['group'] : null;
     $event_model = new Event_Model();
     $events = $event_model->getUpcoming($group_name, $official, false);
     // Creation of the iCal content
     $cache_entry = 'ical-' . (isset($group_name) ? $group_name : '') . '-' . ($official ? 'official' : 'non-official');
     $content = Cache::read($cache_entry);
     if (!$content) {
         require_once APP_DIR . 'classes/class.iCalcreator.php';
         $cal = new vcalendar();
         $cal->setConfig('unique_id', $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']);
         $cal->setProperty('method', 'PUBLISH');
         $cal->setProperty('x-wr-calname', $official ? __('EVENTS_TITLE_OFFICIAL') : __('EVENTS_TITLE_NONOFFICIAL'));
         $cal->setProperty('X-WR-CALDESC', '');
         $cal->setProperty('X-WR-TIMEZONE', date('e'));
         foreach ($events as $event) {
             $vevent = new vevent();
             $vevent->setProperty('dtstart', array('year' => (int) date('Y', $event['date_start']), 'month' => (int) date('n', $event['date_start']), 'day' => (int) date('j', $event['date_start']), 'hour' => (int) date('G', $event['date_start']), 'min' => (int) date('i', $event['date_start']), 'sec' => (int) date('s', $event['date_start'])));
             $vevent->setProperty('dtend', array('year' => (int) date('Y', $event['date_end']), 'month' => (int) date('n', $event['date_end']), 'day' => (int) date('j', $event['date_end']), 'hour' => (int) date('G', $event['date_end']), 'min' => (int) date('i', $event['date_end']), 'sec' => (int) date('s', $event['date_end'])));
             $vevent->setProperty('summary', $event['title']);
             $vevent->setProperty('description', $event['message']);
             $cal->setComponent($vevent);
         }
         $content = $cal->createCalendar();
         Cache::write($cache_entry, $content, 2 * 3600);
     }
     $this->set('content', $content);
 }
开发者ID:hugonicolas,项目名称:Site,代码行数:31,代码来源:Event.php

示例15: landing

 public function landing($psid = null)
 {
     //set cookie if sending presenter
     if (isset($this->request->query['psid']) || !is_null($psid)) {
         $psid = isset($this->request->query['psid']) ? $this->request->query['psid'] : $psid;
         $this->Session->delete('logged_in_presenter_site');
         $this->siteUrl = '';
         $this->webSiteInfo->id = 1;
         $this->Session->write('activate_link', $psid);
     }
     $cacheName = 'products_category_' . $this->marketId;
     if (($category = Cache::read($cacheName, 'short')) === false) {
         $category = YouniqueAPI::call("/products/category/1", array("market_id" => $this->marketId));
         if (!empty($trait)) {
             Cache::write($cacheName, $category, 'short');
         }
     }
     if (isset($this->presenterId)) {
         $paidAs = YouniqueAPI::call("/presenter/profile/" . $this->presenterId);
     } else {
         $paidAs = false;
     }
     $this->set('paidAs', $paidAs);
     $this->set('category', $category->category);
 }
开发者ID:kameshwariv,项目名称:testexample,代码行数:25,代码来源:ProductsController.php


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