本文整理汇总了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);
}
}
}
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
示例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>";
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
示例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());
}
}
示例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;
}
示例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;
}
}
示例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'));
}
}