7 * This source file is subject to the new BSD license that is bundled
8 * with this package in the file LICENSE.txt.
9 * It is also available through the world-wide-web at this URL:
10 * http://framework.zend.com/license/new-bsd
11 * If you did not receive a copy of the license and are unable to
12 * obtain it through the world-wide-web, please send an email
13 * to license@zend.com so we can send you a copy immediately.
17 * @subpackage Zend_Cache_Backend
18 * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
19 * @license http://framework.zend.com/license/new-bsd New BSD License
20 * @version $Id: ShMem.php 16971 2009-07-22 18:05:45Z mikaelkael $
24 /** @see Zend_Cache_Backend_Interface */
25 require_once 'Zend/Cache/Backend/Interface.php';
27 /** @see Zend_Cache_Backend_ZendServer */
28 require_once 'Zend/Cache/Backend/ZendServer.php';
33 * @subpackage Zend_Cache_Backend
34 * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
35 * @license http://framework.zend.com/license/new-bsd New BSD License
37 class Zend_Cache_Backend_ZendServer_ShMem
extends Zend_Cache_Backend_ZendServer
implements Zend_Cache_Backend_Interface
42 * @param array $options associative array of options
43 * @throws Zend_Cache_Exception
45 public function __construct(array $options = array())
47 if (!function_exists('zend_shm_cache_store')) {
48 Zend_Cache
::throwException('Zend_Cache_ZendServer_ShMem backend has to be used within Zend Server environment.');
50 parent
::__construct($options);
56 * @param mixed $data Object to store
57 * @param string $id Cache id
58 * @param int $timeToLive Time to live in seconds
61 protected function _store($data, $id, $timeToLive)
63 if (zend_shm_cache_store($this->_options
['namespace'] . '::' . $id,
65 $timeToLive) === false) {
66 $this->_log('Store operation failed.');
75 * @param string $id Cache id
77 protected function _fetch($id)
79 return zend_shm_cache_fetch($this->_options
['namespace'] . '::' . $id);
85 * @param string $id Cache id
86 * @return boolean true if no problem
88 protected function _unset($id)
90 return zend_shm_cache_delete($this->_options
['namespace'] . '::' . $id);
96 protected function _clear()
98 zend_shm_cache_clear($this->_options
['namespace']);