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


PHP Zend_Cache_Backend_Interface::save方法代码示例

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


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

示例1: _swap

 /**
  * Swap object data to disk
  * Actualy swaps data or only unloads it from memory,
  * if object is not changed since last swap
  *
  * @param Zend_Memory_Container_Movable $container
  * @param integer $id
  */
 private function _swap(Zend_Memory_Container_Movable $container, $id)
 {
     if ($container->isLocked()) {
         return;
     }
     if (!$container->isSwapped()) {
         $this->_backend->save($container->getRef(), $this->_managerId . $id, $this->_tags);
     }
     $this->_memorySize -= $this->_sizes[$id];
     $container->markAsSwapped();
     $container->unloadValue();
 }
开发者ID:SalesOneGit,项目名称:s1_magento,代码行数:20,代码来源:Manager.php

示例2: save

 /**
  * Save some data in a cache
  *
  * @param  mixed $data           Data to put in cache (can be another type than string if automatic_serialization is on)
  * @param  string $id             Cache id (if not set, the last cache id will be used)
  * @param  array $tags           Cache tags
  * @param  int $specificLifetime If != false, set a specific lifetime for this cache record (null => infinite lifetime)
  * @param  int   $priority         integer between 0 (very low priority) and 10 (maximum priority) used by some particular backends
  * @throws Zend_Cache_Exception
  * @return boolean True if no problem
  */
 public function save($data, $id = null, $tags = array(), $specificLifetime = false, $priority = 8)
 {
     if (!$this->_options['caching']) {
         return true;
     }
     if ($id === null) {
         $id = $this->_lastId;
     } else {
         $id = $this->_id($id);
     }
     self::_validateIdOrTag($id);
     self::_validateTagsArray($tags);
     if ($this->_options['automatic_serialization']) {
         // we need to serialize datas before storing them
         $data = serialize($data);
     } else {
         if (!is_string($data)) {
             Zend_Cache::throwException("Datas must be string or set automatic_serialization = true");
         }
     }
     // automatic cleaning
     if ($this->_options['automatic_cleaning_factor'] > 0) {
         $rand = rand(1, $this->_options['automatic_cleaning_factor']);
         if ($rand == 1) {
             if ($this->_extendedBackend) {
                 // New way
                 if ($this->_backendCapabilities['automatic_cleaning']) {
                     $this->clean(Zend_Cache::CLEANING_MODE_OLD);
                 } else {
                     $this->_log('Zend_Cache_Core::save() / automatic cleaning is not available/necessary with this backend');
                 }
             } else {
                 // Deprecated way (will be removed in next major version)
                 if (method_exists($this->_backend, 'isAutomaticCleaningAvailable') && $this->_backend->isAutomaticCleaningAvailable()) {
                     $this->clean(Zend_Cache::CLEANING_MODE_OLD);
                 } else {
                     $this->_log('Zend_Cache_Core::save() / automatic cleaning is not available/necessary with this backend');
                 }
             }
         }
     }
     if ($this->_options['ignore_user_abort']) {
         $abort = ignore_user_abort(true);
     }
     if ($this->_extendedBackend && $this->_backendCapabilities['priority']) {
         $result = $this->_backend->save($data, $id, $tags, $specificLifetime, $priority);
     } else {
         $result = $this->_backend->save($data, $id, $tags, $specificLifetime);
     }
     if ($this->_options['ignore_user_abort']) {
         ignore_user_abort($abort);
     }
     if (!$result) {
         // maybe the cache is corrupted, so we remove it !
         if ($this->_options['logging']) {
             $this->_log("Zend_Cache_Core::save() : impossible to save cache (id={$id})");
         }
         $this->_backend->remove($id);
         return false;
     }
     if ($this->_options['write_control']) {
         $data2 = $this->_backend->load($id, true);
         if ($data != $data2) {
             $this->_log('Zend_Cache_Core::save() / write_control : written and read data do not match');
             $this->_backend->remove($id);
             return false;
         }
     }
     return true;
 }
开发者ID:modulexcite,项目名称:zfopenid,代码行数:81,代码来源:Core.php

示例3: save

 /**
  * Save some data in a cache
  *
  * @param  mixed $data           Data to put in cache (can be another type than string if automatic_serialization is on)
  * @param  string $id             Cache id (if not set, the last cache id will be used)
  * @param  array $tags           Cache tags
  * @param  int $specificLifetime If != false, set a specific lifetime for this cache record (null => infinite lifetime)
  * @param  int   $priority         integer between 0 (very low priority) and 10 (maximum priority) used by some particular backends
  * @throws Zend_Cache_Exception
  * @return boolean True if no problem
  */
 public function save($data, $id = null, $tags = array(), $specificLifetime = false, $priority = 8)
 {
     if (!$this->_options['caching']) {
         return true;
     }
     if ($id === null) {
         $id = $this->_lastId;
     } else {
         $id = $this->_id($id);
     }
     self::_validateIdOrTag($id);
     self::_validateTagsArray($tags);
     if ($this->_options['automatic_serialization']) {
         // we need to serialize datas before storing them
         $data = serialize($data);
     } else {
         if (!is_string($data)) {
             Zend_Cache::throwException("Datas must be string or set automatic_serialization = true");
         }
     }
     // automatic cleaning
     if ($this->_options['automatic_cleaning_factor'] > 0) {
         $rand = rand(1, $this->_options['automatic_cleaning_factor']);
         if ($rand == 1) {
             //  new way                 || deprecated way
             if ($this->_extendedBackend || method_exists($this->_backend, 'isAutomaticCleaningAvailable')) {
                 $this->_log("Zend_Cache_Core::save(): automatic cleaning running", 7);
                 $this->clean(Zend_Cache::CLEANING_MODE_OLD);
             } else {
                 $this->_log("Zend_Cache_Core::save(): automatic cleaning is not available/necessary with current backend", 4);
             }
         }
     }
     $this->_log("Zend_Cache_Core: save item '{$id}'", 7);
     if ($this->_options['ignore_user_abort']) {
         $abort = ignore_user_abort(true);
     }
     if ($this->_extendedBackend && $this->_backendCapabilities['priority']) {
         $result = $this->_backend->save($data, $id, $tags, $specificLifetime, $priority);
     } else {
         $result = $this->_backend->save($data, $id, $tags, $specificLifetime);
     }
     if ($this->_options['ignore_user_abort']) {
         ignore_user_abort($abort);
     }
     if (!$result) {
         // maybe the cache is corrupted, so we remove it !
         $this->_log("Zend_Cache_Core::save(): failed to save item '{$id}' -> removing it", 4);
         $this->_backend->remove($id);
         return false;
     }
     if ($this->_options['write_control']) {
         $data2 = $this->_backend->load($id, true);
         if ($data != $data2) {
             $this->_log("Zend_Cache_Core::save(): write control of item '{$id}' failed -> removing it", 4);
             $this->_backend->remove($id);
             return false;
         }
     }
     return true;
 }
开发者ID:andrelsguerra,项目名称:pequiambiental,代码行数:72,代码来源:Core.php

示例4: write

 /**
  * Writes $contents to storage
  *
  * @param  mixed $contents
  * @throws Zend_Auth_Storage_Exception If writing $contents to storage is impossible
  * @return void
  */
 public function write($contents)
 {
     $this->_backend->save($contents, $this->_id);
 }
开发者ID:hype-,项目名称:xi-zend,代码行数:11,代码来源:CacheStorage.php


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