WinCacheCache.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <?php
  2. namespace Doctrine\Common\Cache;
  3. use function count;
  4. use function is_array;
  5. use function wincache_ucache_clear;
  6. use function wincache_ucache_delete;
  7. use function wincache_ucache_exists;
  8. use function wincache_ucache_get;
  9. use function wincache_ucache_info;
  10. use function wincache_ucache_meminfo;
  11. use function wincache_ucache_set;
  12. /**
  13. * WinCache cache provider.
  14. *
  15. * @deprecated Deprecated without replacement in doctrine/cache 1.11. This class will be dropped in 2.0
  16. *
  17. * @link www.doctrine-project.org
  18. */
  19. class WinCacheCache extends CacheProvider
  20. {
  21. /**
  22. * {@inheritdoc}
  23. */
  24. protected function doFetch($id)
  25. {
  26. return wincache_ucache_get($id);
  27. }
  28. /**
  29. * {@inheritdoc}
  30. */
  31. protected function doContains($id)
  32. {
  33. return wincache_ucache_exists($id);
  34. }
  35. /**
  36. * {@inheritdoc}
  37. */
  38. protected function doSave($id, $data, $lifeTime = 0)
  39. {
  40. return wincache_ucache_set($id, $data, $lifeTime);
  41. }
  42. /**
  43. * {@inheritdoc}
  44. */
  45. protected function doDelete($id)
  46. {
  47. return wincache_ucache_delete($id);
  48. }
  49. /**
  50. * {@inheritdoc}
  51. */
  52. protected function doFlush()
  53. {
  54. return wincache_ucache_clear();
  55. }
  56. /**
  57. * {@inheritdoc}
  58. */
  59. protected function doFetchMultiple(array $keys)
  60. {
  61. return wincache_ucache_get($keys);
  62. }
  63. /**
  64. * {@inheritdoc}
  65. */
  66. protected function doSaveMultiple(array $keysAndValues, $lifetime = 0)
  67. {
  68. $result = wincache_ucache_set($keysAndValues, null, $lifetime);
  69. return empty($result);
  70. }
  71. /**
  72. * {@inheritdoc}
  73. */
  74. protected function doDeleteMultiple(array $keys)
  75. {
  76. $result = wincache_ucache_delete($keys);
  77. return is_array($result) && count($result) !== count($keys);
  78. }
  79. /**
  80. * {@inheritdoc}
  81. */
  82. protected function doGetStats()
  83. {
  84. $info = wincache_ucache_info();
  85. $meminfo = wincache_ucache_meminfo();
  86. return [
  87. Cache::STATS_HITS => $info['total_hit_count'],
  88. Cache::STATS_MISSES => $info['total_miss_count'],
  89. Cache::STATS_UPTIME => $info['total_cache_uptime'],
  90. Cache::STATS_MEMORY_USAGE => $meminfo['memory_total'],
  91. Cache::STATS_MEMORY_AVAILABLE => $meminfo['memory_free'],
  92. ];
  93. }
  94. }