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


PHP Zend_Cache::load方法代码示例

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


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

示例1: jsAction

 /**
  * Минификация яваскриптов
  * 
  * @return void
  */
 public function jsAction()
 {
     $this->_response->setHeader('Content-Type', 'text/javascript', true);
     if (isset($this->_params['files'])) {
         $files = explode(',', $this->_params['files']);
         foreach ($files as $key => $file) {
             $file = $this->_jsdir . trim($file) . '.js';
             if (file_exists($file)) {
                 $files[$key] = $file;
             }
         }
         if (!empty($files)) {
             $cacheid = 'minify_js_' . md5(implode(',', $files));
             $this->_cache->setMasterFiles($files);
             if ($this->_cache->test($cacheid)) {
                 $this->_response->setBody($this->_cache->load($cacheid));
             } else {
                 require_once 'Phorm/Plugin/jsmin.php';
                 $str = '';
                 foreach ($files as $file) {
                     $str .= file_get_contents($file) . PHP_EOL;
                 }
                 $js = JSMin::minify($str);
                 $this->_cache->save($js, $cacheid);
                 $this->_response->setBody($js);
             }
         }
     }
 }
开发者ID:ei-grad,项目名称:phorm,代码行数:34,代码来源:Minify.php

示例2: get

 /** Perform a curl request based on url provided
  * @access public
  * @param string $method
  * @param array $params
  * @return type
  */
 public function get($method, $params)
 {
     $url = $this->createUrl($method, $params);
     if (!$this->_cache->test(md5($url))) {
         $config = array('adapter' => 'Zend_Http_Client_Adapter_Curl', 'curloptions' => array(CURLOPT_POST => true, CURLOPT_USERAGENT => $_SERVER["HTTP_USER_AGENT"], CURLOPT_FOLLOWLOCATION => true, CURLOPT_RETURNTRANSFER => true, CURLOPT_LOW_SPEED_TIME => 1));
         $client = new Zend_Http_Client($url, $config);
         $response = $client->request();
         $data = $response->getBody();
         $this->_cache->save($data);
     } else {
         $data = $this->_cache->load(md5($url));
     }
     return Zend_Json_Decoder::decode($data, Zend_Json::TYPE_OBJECT);
 }
开发者ID:lesleyauk,项目名称:findsorguk,代码行数:20,代码来源:Twfy.php

示例3: get

 /**
  *
  * @param string $id
  * @return boolean|array
  */
 public function get($id = '')
 {
     if ($id == '') {
         $id = $this->_id;
     }
     if ($id == '') {
         throw new ZendT_Exception('Favor informar o id do cache!');
     }
     $data = $this->_cache->load($id);
     if (!$data) {
         return false;
     }
     return unserialize($data);
 }
开发者ID:rtsantos,项目名称:mais,代码行数:19,代码来源:Cache.php

示例4: getData

 /** Get data from the endpoint
  * @access protected
  * @return string
  */
 protected function getData()
 {
     $key = md5($this->_uri);
     if (!$this->_cache->test($key)) {
         $graph = new EasyRdf_Graph(self::URI . $this->_uri . self::SUFFIX);
         $graph->load();
         $data = $graph->resource(self::URI . $this->_uri);
         $this->_cache->save($data);
     } else {
         $data = $this->_cache->load($key);
     }
     EasyRdf_Namespace::set('dcterms', 'http://purl.org/dc/terms/');
     EasyRdf_Namespace::set('pleiades', 'http://pleiades.stoa.org/places/vocab#');
     return $data;
 }
开发者ID:lesleyauk,项目名称:findsorguk,代码行数:19,代码来源:PleiadesMintRdf.php

示例5: cacheRenderedPage

 public function cacheRenderedPage($cache, $options)
 {
     // If the options are a Zend_Config object, convert to an array
     if ($options instanceof Zend_Config) {
         $options = $options->toArray();
     }
     // If the lifetime has been configured use it else default it.
     if (isset($options['lifetime'])) {
         $this->_zendPageCacheDuration = $options['lifetime'];
     } else {
         $this->_zendPageCacheDuration = 1800;
         // half an hour
     }
     // If the key has been configured use it else default it.
     if (isset($options['key'])) {
         $this->_zendPageCacheKey = $options['key'];
     } else {
         $this->_zendPageCacheKey = $_SERVER['REQUEST_URI'];
     }
     // Prepend the key to prevent namespace collisions and
     // remove unsupported chars
     $this->_zendPageCacheKey = 'ZtalPage' . str_replace('/', '', $this->_zendPageCacheKey);
     // Store the cache object
     $this->_zendPageCache = $cache;
     // Check if the cache item exists and, if it does, fetch it
     $this->_zendPageCacheContent = $this->_zendPageCache->load($this->_zendPageCacheKey);
     // return whether a valid cache item could be fetched.
     return $this->_zendPageCacheContent != false;
 }
开发者ID:jo-m,项目名称:ecamp3,代码行数:29,代码来源:View.php

示例6: connect

 /**
  * Connects to the API and logs in
  *
  * @param string $rest_url
  * @param string $username
  * @param string $password
  * @param string $md5_password
  * @return boolean
  */
 function connect($rest_url = null, $username = null, $password = null, $md5_password = true)
 {
     if ($this->cache && ($this->session = $this->cache->load('suiteSession'))) {
         $this->logged_in = TRUE;
     }
     if (!$this->logged_in) {
         if (!is_null($rest_url)) {
             $this->rest_url = $rest_url;
         }
         if (!is_null($username)) {
             $this->username = $username;
         }
         if (!is_null($password)) {
             $this->password = $password;
         }
         $this->logged_in = FALSE;
         if ($this->login($md5_password)) {
             $this->logged_in = TRUE;
             if ($this->cache) {
                 $this->cache->save($this->session, 'suiteSession');
             }
         }
     }
     return $this->logged_in;
 }
开发者ID:irontec,项目名称:SugarCRM-REST-API-Wrapper-Class,代码行数:34,代码来源:Rest.php

示例7: getData

 /** Get the data for a postcode
  * @access public
  * @param string $postcode
  * @return array
  * @throws Pas_Geo_Exception
  */
 public function getData($postcode)
 {
     if ($this->_validator->isValid($postcode)) {
         $postcode = str_replace(' ', '', $postcode);
     } else {
         throw new Pas_Geo_Exception('Invalid postcode sent');
     }
     $key = md5($postcode);
     if (!$this->_cache->test($key)) {
         $response = $this->_get($postcode);
         $this->_cache->save($response);
     } else {
         $response = $this->_cache->load($key);
     }
     $geo = json_decode($response);
     return array('lat' => $geo->wgs84_lat, 'lon' => $geo->wgs84_lon);
 }
开发者ID:lesleyauk,项目名称:findsorguk,代码行数:23,代码来源:PostCodeToGeo.php

示例8: cleanAllCachesAction

 /**
  * Metodo que faz limpeza do Cache (Memcached ou Filesystem)
  * das duas instancias de cache do MPE: cache_FS e cache_acl
  * 
  * Como chamar via admim:
  * 
  * http://[mpe-dominio]/cache/clean-all-caches
  * 
  * @author esilva
  * 
  * @param Zend_Cache $cache
  */
 public function cleanAllCachesAction(Zend_Cache $cache = null)
 {
     $this->_helper->layout()->disableLayout();
     $this->_helper->viewRenderer->setNoRender();
     $this->cache = Zend_Registry::get('cache_FS');
     $this->cache2 = Zend_Registry::get('cache_acl');
     echo "<br>Inserindo conteudo no Cache (Memcached ou Filesystem) <br><br>";
     $this->cache->save('conteudo variavel teste eh este!!', 'teste');
     $testando = $this->cache->load('teste');
     $this->cache2->save('conteudo variavel testeAcl eh este!!', 'testeAcl');
     $testandoAcl = $this->cache2->load('testeAcl');
     sleep(1);
     echo "";
     var_dump('teste_var (cache): ', $testando);
     var_dump('teste_var_acl (cache): ', $testandoAcl);
     echo "<br><BR>LIMPANDO CACHE!!!<br><BR>";
     // clean all records
     $this->cache->clean(Zend_Cache::CLEANING_MODE_ALL);
     $this->cache2->clean(Zend_Cache::CLEANING_MODE_ALL);
     // clean only outdated
     $this->cache->clean(Zend_Cache::CLEANING_MODE_OLD);
     $this->cache2->clean(Zend_Cache::CLEANING_MODE_OLD);
     sleep(2);
     echo "<br> [Verificação da limpeza do cache]<Br><BR>";
     $testando = $this->cache->load('teste');
     $testando2 = $this->cache->load('teste2');
     $testando3 = $this->cache->load('teste3');
     $testandoAcl = $this->cache2->load('testeAcl');
     //recupera do cache
     if ($testando == false) {
         echo "variavel [teste] não mais existe<br>";
         echo "variavel [teste2] não mais existe<br>";
         echo "variavel [teste3] não mais existe<br>";
         echo "variavel [testeAcl] não mais existe<br>";
     } else {
         echo "variavel [teste] existe no cache: ";
         echo "teste: " . $testando . "<br>";
         echo "variavel [teste2] existe no cache: ";
         echo "teste2: " . $testando2 . "<br>";
         echo "variavel [teste3] existe no cache: ";
         echo "teste3: " . $testando3 . "<br>";
         echo "variavel [testeAcl] existe no cache: ";
         echo "testeAcl: " . $testandoAcl . "<br>";
     }
 }
开发者ID:Lazaro-Gallo,项目名称:psmn,代码行数:57,代码来源:CacheController.php

示例9: _loadTableNames

 /**
  * Load Table Names
  *
  * Looks at the DB and produces an array of valid table names.
  *
  * @return void
  */
 private function _loadTableNames()
 {
     if ($this->_cache && ($tableNames = $this->_cache->load('rsc_simpledb_tablenames'))) {
         $this->_tableNames = $tableNames;
     }
     $this->_tableNames = $this->_db->listTables();
     if ($this->_cache) {
         $this->_saveTableNamesCache();
     }
 }
开发者ID:jfro,项目名称:php-simpledb,代码行数:17,代码来源:SimpleDb.php

示例10: fetchRow

 /** Fetch one result
  * @access public
  * @param array $where
  * @param string $order
  * @return Object
  */
 public function fetchRow($where = null, $order = null)
 {
     $id = md5($where->__toString());
     if (!$this->_cache->test($id) || !$this->cache_result) {
         $result = parent::fetchRow($where, $order);
         $this->_cache->save($result);
         return $result;
     } else {
         return $this->_cache->load($id);
     }
 }
开发者ID:lesleyauk,项目名称:findsorguk,代码行数:17,代码来源:Caching.php

示例11: fetchPairs

 /** Fetch pairs from the model
  * @access public
  * @param string $sql
  * @param array $bind
  * @return array
  */
 public function fetchPairs($sql, $bind = array())
 {
     $id = md5($sql);
     if (!$this->_cache->test($id) || !$this->cache_result) {
         $result = parent::fetchPairs($sql, $bind);
         $this->_cache->save($result);
         return $result;
     } else {
         return $this->_cache->load($id);
     }
 }
开发者ID:lesleyauk,项目名称:findsorguk,代码行数:17,代码来源:Abstract.php

示例12: get

 /**
  * magic method for get cache value
  * 
  * @param string $key    the key in the cache container
  * @param string $prefix the prefix used for grouping
  * 
  * @return mixed the value in the cache
  */
 public function get($key, $prefix = null)
 {
     if (!is_null($prefix)) {
         $prevPrefix = $this->addPrefix($prefix);
     }
     $value = $this->cache->load($key);
     if (!is_null($prefix)) {
         // revert to the default prefix
         $this->setPrefix($prevPrefix);
     }
     return $value;
 }
开发者ID:ngchie,项目名称:system,代码行数:20,代码来源:Cache.php

示例13: getQueues

 /**
  * Get an array of all available queues
  *
  * @return array
  */
 public function getQueues()
 {
     $queues = $this->_cache->load(self::DEFAULT_QUEUE_KEY);
     if ($queues === false) {
         return array();
     }
     $queue_names = array();
     foreach ($queues as $queue) {
         $queue_names[] = $queue['name'];
     }
     return $queue_names;
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:17,代码来源:Cache.php

示例14: inPasswordList

 /**
  * Tests if the password appears on a (weak) password list. The list should
  * be a simpe newline separated list of (lowercase) passwords.
  *
  * @param string $parameter Filename of the password list, relative to APPLICATION_PATH
  * @param string $password  The password
  */
 protected function inPasswordList($parameter, $password)
 {
     if (empty($parameter)) {
         return;
     }
     if ($this->cache) {
         $passwordList = $this->cache->load('weakpasswordlist');
     }
     if (empty($passwordList)) {
         $filename = __DIR__ . '/../../../docs/' . ltrim($parameter, '/');
         if (!file_exists($filename)) {
             throw new \Gems_Exception("Unable to load password list '{$filename}'");
         }
         $passwordList = explode("\n", file_get_contents($filename));
         if ($this->cache) {
             $this->cache->save($passwordList, 'weakpasswordlist');
         }
     }
     if (null === $password) {
         $this->_addError($this->translate->_('should not appear in the list of common passwords'));
     } elseif (in_array(strtolower($password), $passwordList)) {
         $this->_addError($this->translate->_('appears in the list of common passwords'));
     }
 }
开发者ID:GemsTracker,项目名称:gemstracker-library,代码行数:31,代码来源:PasswordChecker.php

示例15: load

 /**
  * Test if a cache is available for the given id and (if yes) return it (false else)
  *
  * Pass true as second param if you cached data that does not pass the is_string() check
  *
  * @param string $id Cache ID
  * @param boolean $unserialize Automatically unserialize the cached result
  * @return mixed
  * @throws coding_exception
  */
 public function load($id, $unserialize = false)
 {
     if ($this->cache === false) {
         return false;
     }
     try {
         $data = $this->cache->load($id);
         // Unserialize if needed
         if ($data and $unserialize) {
             $data = unserialize($data);
         }
         return $data;
     } catch (Zend_Cache_Exception $e) {
         throw new coding_exception('Zend Cache Error: ' . $e->getMessage());
     }
 }
开发者ID:bgao-ca,项目名称:moodle-local_mr,代码行数:26,代码来源:cache.php


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