Cache.php 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. <?php
  2. namespace ZN\Caching;
  3. class __USE_STATIC_ACCESS__Cache implements CacheInterface
  4. {
  5. //----------------------------------------------------------------------------------------------------
  6. //
  7. // Yazar : Ozan UYKUN <ozanbote@windowslive.com> | <ozanbote@gmail.com>
  8. // Site : www.zntr.net
  9. // Lisans : The MIT License
  10. // Telif Hakkı: Copyright (c) 2012-2016, zntr.net
  11. //
  12. //----------------------------------------------------------------------------------------------------
  13. //----------------------------------------------------------------------------------------------------
  14. // Protected Cache
  15. //----------------------------------------------------------------------------------------------------
  16. //
  17. // Sürücü bilgisi
  18. //
  19. // @var string
  20. //
  21. //----------------------------------------------------------------------------------------------------
  22. protected $cache;
  23. //----------------------------------------------------------------------------------------------------
  24. // Construct
  25. //----------------------------------------------------------------------------------------------------
  26. //
  27. // @param string $driver
  28. // @return bool
  29. //
  30. //----------------------------------------------------------------------------------------------------
  31. public function __construct($driver = '')
  32. {
  33. $this->cache = \Driver::run('Cache', $driver);
  34. }
  35. //----------------------------------------------------------------------------------------------------
  36. // Call Method
  37. //----------------------------------------------------------------------------------------------------
  38. //
  39. // __call()
  40. //
  41. //----------------------------------------------------------------------------------------------------
  42. use \CallUndefinedMethodTrait;
  43. //----------------------------------------------------------------------------------------------------
  44. // Driver Method
  45. //----------------------------------------------------------------------------------------------------
  46. //
  47. // driver()
  48. //
  49. //----------------------------------------------------------------------------------------------------
  50. use \DriverMethodTrait;
  51. //----------------------------------------------------------------------------------------------------
  52. // Error Control
  53. //----------------------------------------------------------------------------------------------------
  54. //
  55. // $error
  56. // $success
  57. //
  58. // error()
  59. // success()
  60. //
  61. //----------------------------------------------------------------------------------------------------
  62. use \ErrorControlTrait;
  63. //----------------------------------------------------------------------------------------------------
  64. // Data Manipulation Methods Başlangıç
  65. //----------------------------------------------------------------------------------------------------
  66. //----------------------------------------------------------------------------------------------------
  67. // Select
  68. //----------------------------------------------------------------------------------------------------
  69. //
  70. // @param string $key
  71. // @return mixed
  72. //
  73. //----------------------------------------------------------------------------------------------------
  74. public function select($key = '')
  75. {
  76. return $this->cache->select($key);
  77. }
  78. //----------------------------------------------------------------------------------------------------
  79. // Insert
  80. //----------------------------------------------------------------------------------------------------
  81. //
  82. // @param string $key
  83. // @param variable $var
  84. // @param numeric $time
  85. // @param mixed $expressed
  86. // @return bool
  87. //
  88. //----------------------------------------------------------------------------------------------------
  89. public function insert($key = '', $var = '', $time = 60, $compressed = false)
  90. {
  91. return $this->cache->insert($key, $var, $time, $compressed);
  92. }
  93. //----------------------------------------------------------------------------------------------------
  94. // Delete
  95. //----------------------------------------------------------------------------------------------------
  96. //
  97. // @param string $key
  98. // @return mixed
  99. //
  100. //----------------------------------------------------------------------------------------------------
  101. public function delete($key = '')
  102. {
  103. return $this->cache->delete($key);
  104. }
  105. //----------------------------------------------------------------------------------------------------
  106. // Data Manipulation Methods Bitiş
  107. //----------------------------------------------------------------------------------------------------
  108. //----------------------------------------------------------------------------------------------------
  109. // Increment Methods Başlangıç
  110. //----------------------------------------------------------------------------------------------------
  111. //----------------------------------------------------------------------------------------------------
  112. // Increment
  113. //----------------------------------------------------------------------------------------------------
  114. //
  115. // @param string $key
  116. // @param numeric $increment
  117. // @return void
  118. //
  119. //----------------------------------------------------------------------------------------------------
  120. public function increment($key = '', $increment = 1)
  121. {
  122. return $this->cache->increment($key, $increment);
  123. }
  124. //----------------------------------------------------------------------------------------------------
  125. // Deccrement
  126. //----------------------------------------------------------------------------------------------------
  127. //
  128. // @param string $key
  129. // @param numeric $decrement
  130. // @return void
  131. //
  132. //----------------------------------------------------------------------------------------------------
  133. public function decrement($key = '', $decrement = 1)
  134. {
  135. return $this->cache->decrement($key, $decrement);
  136. }
  137. //----------------------------------------------------------------------------------------------------
  138. // Increment Methods Bitiş
  139. //----------------------------------------------------------------------------------------------------
  140. //----------------------------------------------------------------------------------------------------
  141. // Info Methods Başlangıç
  142. //----------------------------------------------------------------------------------------------------
  143. //----------------------------------------------------------------------------------------------------
  144. // Info
  145. //----------------------------------------------------------------------------------------------------
  146. //
  147. // @param mixed $info
  148. // @return mixed
  149. //
  150. //----------------------------------------------------------------------------------------------------
  151. public function info($type = 'user')
  152. {
  153. return $this->cache->info($type);
  154. }
  155. //----------------------------------------------------------------------------------------------------
  156. // Get Meta Data
  157. //----------------------------------------------------------------------------------------------------
  158. //
  159. // @param string $key
  160. // @return mixed
  161. //
  162. //----------------------------------------------------------------------------------------------------
  163. public function getMetaData($key = '')
  164. {
  165. return $this->cache->getMetaData($key);
  166. }
  167. //----------------------------------------------------------------------------------------------------
  168. // Is Supported
  169. //----------------------------------------------------------------------------------------------------
  170. //
  171. // @param void
  172. // @return bool
  173. //
  174. //----------------------------------------------------------------------------------------------------
  175. public function isSupported()
  176. {
  177. return $this->cache->isSupported();
  178. }
  179. //----------------------------------------------------------------------------------------------------
  180. // Clean
  181. //----------------------------------------------------------------------------------------------------
  182. //
  183. // @param void
  184. // @return void
  185. //
  186. //----------------------------------------------------------------------------------------------------
  187. public function clean()
  188. {
  189. return $this->cache->clean();
  190. }
  191. //----------------------------------------------------------------------------------------------------
  192. // Info Methods Bitiş
  193. //----------------------------------------------------------------------------------------------------
  194. }