gustav/cache

v0.5.1 2016-04-10 11:54 UTC

README

A small and simple PHP cache system, which implements PSR-6 interfaces.

Build Status

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 that 0 and lower means, that the items will not expire. Default is 0.
  • 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.