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


PHP Zend_Cache::save方法代码示例

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


在下文中一共展示了Zend_Cache::save方法的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: set

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

示例3: 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

示例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: 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

示例6: 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

示例7: _saveTableNamesCache

 /**
  * Save Table Names Cache
  *
  * Saves the current value of $_tableNames into the cache.
  *
  * @return void
  */
 protected function _saveTableNamesCache()
 {
     if (!$this->_cache) {
         return;
     }
     // store table list for 12 hours
     $this->_cache->save($this->_tableNames, 'rsc_simpledb_tablenames', array(), 43200);
 }
开发者ID:jfro,项目名称:php-simpledb,代码行数:15,代码来源:SimpleDb.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: 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

示例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: send

 /**
  * Push an element onto the end of the queue
  *
  * @param  mixed  $message message to send to the queue
  * @param  string $name    queue name
  * @return Zend_Queue_Message
  */
 public function send($message, $name = null)
 {
     if ($name !== null) {
         $this->setActiveQueue($name);
     } else {
         $name = $this->getActiveQueue();
     }
     $data = array('message_id' => md5(uniqid(rand(), true)), 'handle' => null, 'body' => $message, 'md5' => md5($message));
     $this->_cache->save($data, $data['message_id'], array($name));
     $config = array('queue' => $this, 'data' => $data);
     Zend_Loader::loadClass($this->_msgClass);
     return new $this->_msgClass($config);
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:20,代码来源:Cache.php

示例12: save

 /**
  * Save data to the cache
  *
  * @param mixed $data The data to be saved, if data fails is_string() check, then it will be serialized.
  *                    You then must unserialize it when it is retrieved from cache or call the load method
  *                    like so: $cache->load('cacheId', true);
  * @param string $id Cache id (if not set, the last cache id will be used)
  * @return boolean
  * @throws coding_exception
  */
 public function save($data, $id = null)
 {
     if ($this->cache === false) {
         return true;
     }
     try {
         if (!is_string($data)) {
             $data = serialize($data);
         }
         return $this->cache->save($data, $id);
     } catch (Zend_Cache_Exception $e) {
         throw new coding_exception('Zend Cache Error: ' . $e->getMessage());
     }
 }
开发者ID:bgao-ca,项目名称:moodle-local_mr,代码行数:24,代码来源:cache.php

示例13: set

 /**
  * method for set cache value with specific life time
  * 
  * @param string  $key       the key in the cache container
  * @param mixed   $value     the value in the cache container 
  *                           if automatic_serialization is not set (set by default), require to be a string
  * @param string  $prefix    the prefix used for grouping
  * @param int     $lifetime  if != false, set a specific lifetime for this cache record (null => infinite lifetime)
  * 
  * @return mixed the value in the cache for the key
  */
 public function set($key, $value, $prefix = null, $lifetime = false)
 {
     if (!is_null($prefix)) {
         $prevPrefix = $this->addPrefix($prefix);
     }
     $saveStatus = $this->cache->save($value, $key, array(), $lifetime);
     if (!is_null($prefix)) {
         // revert to the default prefix
         $this->setPrefix($prevPrefix);
     }
     if ($saveStatus !== FALSE) {
         return $value;
     }
     return FALSE;
 }
开发者ID:ngchie,项目名称:system,代码行数:26,代码来源:Cache.php

示例14: reverseGeoCode

 /** Reverse geocode for woeid and other data
  * @param float $lat
  * @param float $lon
  * @return array|boolean
  */
 public function reverseGeoCode($lat, $lon)
 {
     if (!is_null($lat) && !is_null($lon)) {
         $key = 'geocode' . md5($lat . $lon);
         if (!($place = $this->_cache->load($key))) {
             $yql = 'SELECT * FROM geo.placefinder where text="' . $lat . ',' . $lon . '" and gflags="R"';
             //    $yql = 'SELECT * FROM xml WHERE url="http://where.yahooapis.com/geocode?location=' . $lat . '+' .  $lon
             //    . '&gflags=R&appid=' . $this->_appID . '"';
             $place = $this->_oauth->execute($yql, $this->_accessToken, $this->_accessSecret, $this->_accessExpiry, $this->_handle);
             $this->_cache->save($place);
         } else {
             $place = $this->_cache->load($key);
         }
         if (sizeof($place) > 0) {
             $place = $this->_parser->parseGeocoded($place);
             return $place;
         } else {
             return false;
         }
     } else {
         return false;
     }
 }
开发者ID:lesleyauk,项目名称:findsorguk,代码行数:28,代码来源:GeoPlanet.php

示例15: 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


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