ZendDataCache.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. namespace Doctrine\Common\Cache;
  3. use function zend_shm_cache_clear;
  4. use function zend_shm_cache_delete;
  5. use function zend_shm_cache_fetch;
  6. use function zend_shm_cache_store;
  7. /**
  8. * Zend Data Cache cache driver.
  9. *
  10. * @link www.doctrine-project.org
  11. */
  12. class ZendDataCache extends CacheProvider
  13. {
  14. /**
  15. * {@inheritdoc}
  16. */
  17. protected function doFetch($id)
  18. {
  19. return zend_shm_cache_fetch($id);
  20. }
  21. /**
  22. * {@inheritdoc}
  23. */
  24. protected function doContains($id)
  25. {
  26. return zend_shm_cache_fetch($id) !== false;
  27. }
  28. /**
  29. * {@inheritdoc}
  30. */
  31. protected function doSave($id, $data, $lifeTime = 0)
  32. {
  33. return zend_shm_cache_store($id, $data, $lifeTime);
  34. }
  35. /**
  36. * {@inheritdoc}
  37. */
  38. protected function doDelete($id)
  39. {
  40. return zend_shm_cache_delete($id);
  41. }
  42. /**
  43. * {@inheritdoc}
  44. */
  45. protected function doFlush()
  46. {
  47. $namespace = $this->getNamespace();
  48. if (empty($namespace)) {
  49. return zend_shm_cache_clear();
  50. }
  51. return zend_shm_cache_clear($namespace);
  52. }
  53. /**
  54. * {@inheritdoc}
  55. */
  56. protected function doGetStats()
  57. {
  58. return null;
  59. }
  60. }