Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

182 рядки
6.1KB

  1. <?php
  2. namespace Config;
  3. use CodeIgniter\Cache\Handlers\DummyHandler;
  4. use CodeIgniter\Cache\Handlers\FileHandler;
  5. use CodeIgniter\Cache\Handlers\MemcachedHandler;
  6. use CodeIgniter\Cache\Handlers\PredisHandler;
  7. use CodeIgniter\Cache\Handlers\RedisHandler;
  8. use CodeIgniter\Cache\Handlers\WincacheHandler;
  9. use CodeIgniter\Config\BaseConfig;
  10. class Cache extends BaseConfig
  11. {
  12. /**
  13. * --------------------------------------------------------------------------
  14. * Primary Handler
  15. * --------------------------------------------------------------------------
  16. *
  17. * The name of the preferred handler that should be used. If for some reason
  18. * it is not available, the $backupHandler will be used in its place.
  19. *
  20. * @var string
  21. */
  22. public $handler = 'file';
  23. /**
  24. * --------------------------------------------------------------------------
  25. * Backup Handler
  26. * --------------------------------------------------------------------------
  27. *
  28. * The name of the handler that will be used in case the first one is
  29. * unreachable. Often, 'file' is used here since the filesystem is
  30. * always available, though that's not always practical for the app.
  31. *
  32. * @var string
  33. */
  34. public $backupHandler = 'dummy';
  35. /**
  36. * --------------------------------------------------------------------------
  37. * Cache Directory Path
  38. * --------------------------------------------------------------------------
  39. *
  40. * The path to where cache files should be stored, if using a file-based
  41. * system.
  42. *
  43. * @var string
  44. *
  45. * @deprecated Use the driver-specific variant under $file
  46. */
  47. public $storePath = WRITEPATH . 'cache/';
  48. /**
  49. * --------------------------------------------------------------------------
  50. * Cache Include Query String
  51. * --------------------------------------------------------------------------
  52. *
  53. * Whether to take the URL query string into consideration when generating
  54. * output cache files. Valid options are:
  55. *
  56. * false = Disabled
  57. * true = Enabled, take all query parameters into account.
  58. * Please be aware that this may result in numerous cache
  59. * files generated for the same page over and over again.
  60. * array('q') = Enabled, but only take into account the specified list
  61. * of query parameters.
  62. *
  63. * @var bool|string[]
  64. */
  65. public $cacheQueryString = false;
  66. /**
  67. * --------------------------------------------------------------------------
  68. * Key Prefix
  69. * --------------------------------------------------------------------------
  70. *
  71. * This string is added to all cache item names to help avoid collisions
  72. * if you run multiple applications with the same cache engine.
  73. *
  74. * @var string
  75. */
  76. public $prefix = '';
  77. /**
  78. * --------------------------------------------------------------------------
  79. * Default TTL
  80. * --------------------------------------------------------------------------
  81. *
  82. * The default number of seconds to save items when none is specified.
  83. *
  84. * WARNING: This is not used by framework handlers where 60 seconds is
  85. * hard-coded, but may be useful to projects and modules. This will replace
  86. * the hard-coded value in a future release.
  87. *
  88. * @var int
  89. */
  90. public $ttl = 60;
  91. /**
  92. * --------------------------------------------------------------------------
  93. * Reserved Characters
  94. * --------------------------------------------------------------------------
  95. *
  96. * A string of reserved characters that will not be allowed in keys or tags.
  97. * Strings that violate this restriction will cause handlers to throw.
  98. * Default: {}()/\@:
  99. * Note: The default set is required for PSR-6 compliance.
  100. *
  101. * @var string
  102. */
  103. public $reservedCharacters = '{}()/\@:';
  104. /**
  105. * --------------------------------------------------------------------------
  106. * File settings
  107. * --------------------------------------------------------------------------
  108. * Your file storage preferences can be specified below, if you are using
  109. * the File driver.
  110. *
  111. * @var array<string, int|string|null>
  112. */
  113. public $file = [
  114. 'storePath' => WRITEPATH . 'cache/',
  115. 'mode' => 0640,
  116. ];
  117. /**
  118. * -------------------------------------------------------------------------
  119. * Memcached settings
  120. * -------------------------------------------------------------------------
  121. * Your Memcached servers can be specified below, if you are using
  122. * the Memcached drivers.
  123. *
  124. * @see https://codeigniter.com/user_guide/libraries/caching.html#memcached
  125. *
  126. * @var array<string, boolean|int|string>
  127. */
  128. public $memcached = [
  129. 'host' => '127.0.0.1',
  130. 'port' => 11211,
  131. 'weight' => 1,
  132. 'raw' => false,
  133. ];
  134. /**
  135. * -------------------------------------------------------------------------
  136. * Redis settings
  137. * -------------------------------------------------------------------------
  138. * Your Redis server can be specified below, if you are using
  139. * the Redis or Predis drivers.
  140. *
  141. * @var array<string, int|string|null>
  142. */
  143. public $redis = [
  144. 'host' => '127.0.0.1',
  145. 'password' => null,
  146. 'port' => 6379,
  147. 'timeout' => 0,
  148. 'database' => 0,
  149. ];
  150. /**
  151. * --------------------------------------------------------------------------
  152. * Available Cache Handlers
  153. * --------------------------------------------------------------------------
  154. *
  155. * This is an array of cache engine alias' and class names. Only engines
  156. * that are listed here are allowed to be used.
  157. *
  158. * @var array<string, string>
  159. */
  160. public $validHandlers = [
  161. 'dummy' => DummyHandler::class,
  162. 'file' => FileHandler::class,
  163. 'memcached' => MemcachedHandler::class,
  164. 'predis' => PredisHandler::class,
  165. 'redis' => RedisHandler::class,
  166. 'wincache' => WincacheHandler::class,
  167. ];
  168. }