No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

Cache.php 6.1KB

hace 2 años
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  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. }