PageRenderTime 31ms CodeModel.GetById 26ms RepoModel.GetById 0ms app.codeStats 0ms

/framework/vendor/zend/Zend/Cache/Backend/ZendServer/Disk.php

http://zoop.googlecode.com/
PHP | 100 lines | 35 code | 9 blank | 56 comment | 2 complexity | d499573f0ac627932b08cde9d1cd2859 MD5 | raw file
Possible License(s): BSD-3-Clause, LGPL-2.1
  1. <?php
  2. /**
  3. * Zend Framework
  4. *
  5. * LICENSE
  6. *
  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.
  14. *
  15. * @category Zend
  16. * @package Zend_Cache
  17. * @subpackage Zend_Cache_Backend
  18. * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. * @version $Id: Disk.php 20096 2010-01-06 02:05:09Z bkarwin $
  21. */
  22. /** @see Zend_Cache_Backend_Interface */
  23. require_once 'Zend/Cache/Backend/Interface.php';
  24. /** @see Zend_Cache_Backend_ZendServer */
  25. require_once 'Zend/Cache/Backend/ZendServer.php';
  26. /**
  27. * @package Zend_Cache
  28. * @subpackage Zend_Cache_Backend
  29. * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
  30. * @license http://framework.zend.com/license/new-bsd New BSD License
  31. */
  32. class Zend_Cache_Backend_ZendServer_Disk extends Zend_Cache_Backend_ZendServer implements Zend_Cache_Backend_Interface
  33. {
  34. /**
  35. * Constructor
  36. *
  37. * @param array $options associative array of options
  38. * @throws Zend_Cache_Exception
  39. */
  40. public function __construct(array $options = array())
  41. {
  42. if (!function_exists('zend_disk_cache_store')) {
  43. Zend_Cache::throwException('Zend_Cache_ZendServer_Disk backend has to be used within Zend Server environment.');
  44. }
  45. parent::__construct($options);
  46. }
  47. /**
  48. * Store data
  49. *
  50. * @param mixed $data Object to store
  51. * @param string $id Cache id
  52. * @param int $timeToLive Time to live in seconds
  53. * @return boolean true if no problem
  54. */
  55. protected function _store($data, $id, $timeToLive)
  56. {
  57. if (zend_disk_cache_store($this->_options['namespace'] . '::' . $id,
  58. $data,
  59. $timeToLive) === false) {
  60. $this->_log('Store operation failed.');
  61. return false;
  62. }
  63. return true;
  64. }
  65. /**
  66. * Fetch data
  67. *
  68. * @param string $id Cache id
  69. */
  70. protected function _fetch($id)
  71. {
  72. return zend_disk_cache_fetch($this->_options['namespace'] . '::' . $id);
  73. }
  74. /**
  75. * Unset data
  76. *
  77. * @param string $id Cache id
  78. * @return boolean true if no problem
  79. */
  80. protected function _unset($id)
  81. {
  82. return zend_disk_cache_delete($this->_options['namespace'] . '::' . $id);
  83. }
  84. /**
  85. * Clear cache
  86. */
  87. protected function _clear()
  88. {
  89. zend_disk_cache_clear($this->_options['namespace']);
  90. }
  91. }