175 lines
6.4 KiB
PHP
175 lines
6.4 KiB
PHP
<?php
|
|
|
|
namespace Config;
|
|
|
|
use CodeIgniter\Cache\CacheInterface;
|
|
use CodeIgniter\Cache\Handlers\DummyHandler;
|
|
use CodeIgniter\Cache\Handlers\FileHandler;
|
|
use CodeIgniter\Cache\Handlers\MemcachedHandler;
|
|
use CodeIgniter\Cache\Handlers\PredisHandler;
|
|
use CodeIgniter\Cache\Handlers\RedisHandler;
|
|
use CodeIgniter\Cache\Handlers\WincacheHandler;
|
|
use CodeIgniter\Config\BaseConfig;
|
|
|
|
class Cache extends BaseConfig
|
|
{
|
|
/**
|
|
* --------------------------------------------------------------------------
|
|
* Primary Handler
|
|
* --------------------------------------------------------------------------
|
|
*
|
|
* The name of the preferred handler that should be used. If for some reason
|
|
* it is not available, the $backupHandler will be used in its place.
|
|
*/
|
|
public string $handler = 'redis';
|
|
|
|
/**
|
|
* --------------------------------------------------------------------------
|
|
* Backup Handler
|
|
* --------------------------------------------------------------------------
|
|
*
|
|
* The name of the handler that will be used in case the first one is
|
|
* unreachable. Often, 'file' is used here since the filesystem is
|
|
* always available, though that's not always practical for the app.
|
|
*/
|
|
public string $backupHandler = 'dummy';
|
|
|
|
/**
|
|
* --------------------------------------------------------------------------
|
|
* Key Prefix
|
|
* --------------------------------------------------------------------------
|
|
*
|
|
* This string is added to all cache item names to help avoid collisions
|
|
* if you run multiple applications with the same cache engine.
|
|
*/
|
|
public string $prefix = '';
|
|
|
|
/**
|
|
* --------------------------------------------------------------------------
|
|
* Default TTL
|
|
* --------------------------------------------------------------------------
|
|
*
|
|
* The default number of seconds to save items when none is specified.
|
|
*
|
|
* WARNING: This is not used by framework handlers where 60 seconds is
|
|
* hard-coded, but may be useful to projects and modules. This will replace
|
|
* the hard-coded value in a future release.
|
|
*/
|
|
public int $ttl = 60;
|
|
|
|
/**
|
|
* --------------------------------------------------------------------------
|
|
* Reserved Characters
|
|
* --------------------------------------------------------------------------
|
|
*
|
|
* A string of reserved characters that will not be allowed in keys or tags.
|
|
* Strings that violate this restriction will cause handlers to throw.
|
|
* Default: {}()/\@:
|
|
*
|
|
* NOTE: The default set is required for PSR-6 compliance.
|
|
*/
|
|
public string $reservedCharacters = '{}()/\@:';
|
|
|
|
/**
|
|
* --------------------------------------------------------------------------
|
|
* File settings
|
|
* --------------------------------------------------------------------------
|
|
*
|
|
* Your file storage preferences can be specified below, if you are using
|
|
* the File driver.
|
|
*
|
|
* @var array{storePath?: string, mode?: int}
|
|
*/
|
|
public array $file = [
|
|
'storePath' => WRITEPATH . 'cache/',
|
|
'mode' => 0640,
|
|
];
|
|
|
|
/**
|
|
* -------------------------------------------------------------------------
|
|
* Memcached settings
|
|
* -------------------------------------------------------------------------
|
|
*
|
|
* Your Memcached servers can be specified below, if you are using
|
|
* the Memcached drivers.
|
|
*
|
|
* @see https://codeigniter.com/user_guide/libraries/caching.html#memcached
|
|
*
|
|
* @var array{host?: string, port?: int, weight?: int, raw?: bool}
|
|
*/
|
|
public array $memcached = [
|
|
'host' => '127.0.0.1',
|
|
'port' => 11211,
|
|
'weight' => 1,
|
|
'raw' => false,
|
|
];
|
|
|
|
/**
|
|
* -------------------------------------------------------------------------
|
|
* Redis settings
|
|
* -------------------------------------------------------------------------
|
|
*
|
|
* Your Redis server can be specified below, if you are using
|
|
* the Redis or Predis drivers.
|
|
*
|
|
* @var array{host?: string, password?: string|null, port?: int, timeout?: int, database?: int}
|
|
*/
|
|
public array $redis = [];
|
|
|
|
/**
|
|
* --------------------------------------------------------------------------
|
|
* Available Cache Handlers
|
|
* --------------------------------------------------------------------------
|
|
*
|
|
* This is an array of cache engine alias' and class names. Only engines
|
|
* that are listed here are allowed to be used.
|
|
*
|
|
* @var array<string, class-string<CacheInterface>>
|
|
*/
|
|
public array $validHandlers = [
|
|
'dummy' => DummyHandler::class,
|
|
'file' => FileHandler::class,
|
|
'memcached' => MemcachedHandler::class,
|
|
'predis' => PredisHandler::class,
|
|
'redis' => RedisHandler::class,
|
|
'wincache' => WincacheHandler::class,
|
|
];
|
|
|
|
/**
|
|
* --------------------------------------------------------------------------
|
|
* Web Page Caching: Cache Include Query String
|
|
* --------------------------------------------------------------------------
|
|
*
|
|
* Whether to take the URL query string into consideration when generating
|
|
* output cache files. Valid options are:
|
|
*
|
|
* false = Disabled
|
|
* true = Enabled, take all query parameters into account.
|
|
* Please be aware that this may result in numerous cache
|
|
* files generated for the same page over and over again.
|
|
* ['q'] = Enabled, but only take into account the specified list
|
|
* of query parameters.
|
|
*
|
|
* @var bool|list<string>
|
|
*/
|
|
public $cacheQueryString = false;
|
|
|
|
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
|
|
// Redis 설정에 .env 값을 할당 (이전 논의된 Docker 호스트 이름 'redis' 사용)
|
|
$this->redis = [
|
|
'host' => env('redis.default.host', '127.0.0.1'),
|
|
'password' => env('redis.default.password', null),
|
|
'port' => (int)env('redis.default.port', 6379),
|
|
'timeout' => (int)env('redis.default.timeout', 0),
|
|
'database' => (int)env('redis.default.database', 0)
|
|
];
|
|
|
|
// 필요하다면, 이 생성자에서 $handler나 $backupHandler 같은 다른 설정도
|
|
// 환경 변수에 따라 동적으로 설정할 수 있습니다.
|
|
}
|
|
}
|