Cache Framework

1.3.3 2020-02-03 13:57 UTC

This package is auto-updated.

Last update: 2024-05-29 04:22:34 UTC


README

This library aims to provide basic functionality to work with (testable, interchangable) Cache implementations

Installation

composer require philippwitzmann/cache

Usage

Create an instance

$dateTimeHandler = new DateTimeHandler();
$arrayCache      = new ArrayCache($dateTimeHandler);

Set Values

$client = new Client([
    'scheme' => 'tcp',
    'host'   => '127.0.0.1',
    'port'   => 6379,
]);
$dateTimeHandler = new DateTimeHandler();
$arrayCache      = new ArrayCache($dateTimeHandler);
$redisCache      = new RedisCache($dateTimeHandler, $client);
$arrayCache->set('key', 'value', 600); // 600 is Lifetime In Seconds so 10Minutes.
$redisCache->set('key', 'value', 600); // 600 is Lifetime In Seconds so 10Minutes.

echo $arrayCache->get('key'); // Outputs: 'value'

Running tests

php vendor/bin/phpunit --configuration config/phpunit.xml