cache.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <?php
  2. declare(strict_types=1);
  3. use Hypervel\Cache\SwooleStore;
  4. use Hypervel\Support\Str;
  5. return [
  6. /*
  7. |--------------------------------------------------------------------------
  8. | Default Cache Store
  9. |--------------------------------------------------------------------------
  10. |
  11. | This option controls the default cache connection that gets used while
  12. | using this caching library. This connection is used when another is
  13. | not explicitly specified when executing a given caching function.
  14. |
  15. */
  16. 'default' => env('CACHE_DRIVER', 'array'),
  17. /*
  18. |--------------------------------------------------------------------------
  19. | Cache Stores
  20. |--------------------------------------------------------------------------
  21. |
  22. | Here you may define all of the cache "stores" for your application as
  23. | well as their drivers. You may even define multiple stores for the
  24. | same cache driver to group types of items stored in your caches.
  25. |
  26. | Supported drivers: "array", "file", "redis", "swoole", "stack", "null"
  27. |
  28. */
  29. 'stores' => [
  30. 'array' => [
  31. 'driver' => 'array',
  32. 'serialize' => false,
  33. ],
  34. 'file' => [
  35. 'driver' => 'file',
  36. 'path' => storage_path('cache/data'),
  37. 'lock_path' => storage_path('cache/data'),
  38. ],
  39. 'redis' => [
  40. 'driver' => 'redis',
  41. 'connection' => 'default',
  42. 'lock_connection' => 'default',
  43. ],
  44. 'swoole' => [
  45. 'driver' => 'swoole',
  46. 'table' => 'default',
  47. 'memory_limit_buffer' => 0.05,
  48. 'eviction_policy' => SwooleStore::EVICTION_POLICY_LRU,
  49. 'eviction_proportion' => 0.05,
  50. 'eviction_interval' => 10000, // milliseconds
  51. ],
  52. 'stack' => [
  53. 'driver' => 'stack',
  54. 'stores' => [
  55. 'swoole' => [
  56. 'ttl' => 3, // seconds
  57. ],
  58. 'redis',
  59. ],
  60. ],
  61. 'database' => [
  62. 'driver' => 'database',
  63. 'connection' => env('DB_CACHE_CONNECTION', env('DB_CONNECTION', 'default')),
  64. 'table' => env('DB_CACHE_TABLE', 'cache'),
  65. 'lock_connection' => env('DB_CACHE_LOCK_CONNECTION'),
  66. 'lock_table' => env('DB_CACHE_LOCK_TABLE', 'cache_locks'),
  67. 'lock_lottery' => [2, 100],
  68. 'lock_timeout' => 86400,
  69. ],
  70. ],
  71. 'swoole_tables' => [
  72. 'default' => [
  73. 'rows' => 1024,
  74. 'bytes' => 10240,
  75. 'conflict_proportion' => 0.2,
  76. ],
  77. ],
  78. /*
  79. |--------------------------------------------------------------------------
  80. | Cache Key Prefix
  81. |--------------------------------------------------------------------------
  82. |
  83. | When utilizing a RAM based store such as APC or Memcached, there might
  84. | be other applications utilizing the same cache. So, we'll specify a
  85. | value to get prefixed to all our keys so we can avoid collisions.
  86. |
  87. */
  88. 'prefix' => env('CACHE_PREFIX', Str::slug(env('APP_NAME', 'hypervel'), '_') . '_cache'),
  89. ];