gustav / cache
A small and simple PHP cache system
v0.7
2020-07-11 13:21 UTC
Requires
- php: ^7.4
- ext-mbstring: *
- gustav/utils: ^0.1
- psr/cache: ^1.0
- psr/simple-cache: ^1.0
Requires (Dev)
- phpunit/phpunit: ~9.2
README
A small and simple PHP cache system, which implements PSR-6 interfaces.
Implementations
- Filesystem: Each cache item pool is a simple file. Cache items are saved with help of PHP's default serialization method.
- Debug: Cache item pools will not be persisted. This is just for testing purposes. Don't use this implementation in production environments.
Usage
//configure the system $config = new \Gustav\Cache\Configuration(); $config->setDirectory("path/to/my/cache/files/"); //load cache manager $manager = \Gustav\Cache\ACacheManager::getInstance($config); //fetch the item pool $pool = $manager->getItemPool("myFileName", $myCreatorFunction);
Configuration
You can set the following configurations in \Gustav\Orm\Configuration
:
setImplementation(string)
: Sets the implementation of the cache manager to use here. Default is\Gustav\Cache\Filesystem\CacheManager
(i.e. the Filesystem cache).setDirectory(string)
: Sets the directory on filesystem, where we save the cache pool files. There's no default value.setDefaultExpiration(integer)
: Sets the default time to live of cache items, if you don't set any explicitly in\Gustav\Cache\CacheItem
. Consider that0
and lower means, that the items will not expire. Default is0
.getLogConiguration(): \Gustav\Utils\Log\Configuration
/setLogConfiguration(\Gustav\Utils\Log\Configuration)
: Configure the error log to use in this cache implementation. By default this uses the default configuration from Utils. See Gustav Utils for further information.