germania-kg/cacheserviceprovider

1.0.5 2022-03-30 10:25 UTC

This package is auto-updated.

Last update: 2024-10-29 05:16:29 UTC


README

Pimple Service Provider for creating phpFastCache services

Packagist PHP version Build Status Scrutinizer Code Quality Code Coverage Build Status

Installation with Composer

$ composer require germania-kg/cacheserviceprovider

Setup

<?php
use Germania\CacheServiceProvider\CacheServiceProvider;

// A. Use with Slim or Pimple
$app = new \Slim\App;
$dic = $app->getContainer();
$dic = new Pimple\Container;

// B. Register Service Provider, 
// Defaults are unsecure!
$csp = new CacheServiceProvider( );
$csp = new CacheServiceProvider( sys_get_tmp_dir(), 3600);

// Pass custom cache directoy and lifetime (seconds)
$csp = new CacheServiceProvider( "path/to/cache", 3600);

// or, leave at defaults: 
$dic->register( $csp  );

Services

Cache.ItemPool

Returns a phpFastCache instance.

$itempool = $dic['Cache.ItemPool'];

Development

$ git clone https://github.com/GermaniaKG/CacheServiceProvider.git
$ cd CacheServiceProvider
$ composer install

Unit tests

Either copy phpunit.xml.dist to phpunit.xml and adapt to your needs, or leave as is. Run PhpUnit test or composer scripts like this:

$ composer test
# or
$ vendor/bin/phpunit