2017 © Pedro PelĂĄez
 

library repository-cache

Implementation of a base repository with cache layer using StashPHP

image

nilportugues/repository-cache

Implementation of a base repository with cache layer using StashPHP

  • Tuesday, August 9, 2016
  • by nilportugues
  • Repository
  • 1 Watchers
  • 4 Stars
  • 218 Installations
  • PHP
  • 0 Dependents
  • 4 Suggesters
  • 0 Forks
  • 1 Open issues
  • 9 Versions
  • 0 % Grown

The README.md

Repository Cache

PHP7 Tested Build Status Scrutinizer Code Quality SensioLabsInsight Latest Stable Version Total Downloads License Donate, (*1)

Repository to be used with nilportugues/repository implementing a PSR-6 cache layer using StashPHP., (*2)

Installation

Use Composer to install the package:, (*3)

$ composer require nilportugues/repository-cache

Cache Drivers

Repository Cache supports all of Stash's drivers:, (*4)

  • System
    • FileSystem
    • Sqlite (requires php-pdo-sqlite extension)
    • APC (requires php-apcu extension)
  • Server
    • Memcached (requires php-memcache or php-memcached extensions)
    • Redis (requires php-redis extension)
  • Specialized
    • Ephemeral (in memory cache)
    • Composite

For more information please check out Stash's documentation., (*5)

Usage

use NilPortugues\Foundation\Infrastructure\Model\Repository\Cache\RepositoryCache;
use Stash\Driver\Ephemeral;
use Stash\Driver\Memcache;
use Stash\Pool;

//---------------------------------------------------------------------------
// Definition of cache drivers
//---------------------------------------------------------------------------
$memcached = new Memcache();
$memcached->setOptions(array('servers' => array('127.0.0.1', '11211')));

$cachePool = new Pool();
$cachePool->setDriver(new Ephemeral()); //hit in memory first as always will be faster
$cachePool->setDriver($memcached); //hit memcached second.

$ttl = 3600; //time in second for cache to expire.
$cacheNamespace = Color::class;

//---------------------------------------------------------------------------
// Adding cache to an existing repository
//---------------------------------------------------------------------------
$sqlRepository = new MySQLColorRepository();
$repository = new RepositoryCache($cachePool, $repository, $cacheNamespace, $ttl);

//---------------------------------------------------------------------------
// Now use as normal... 
//---------------------------------------------------------------------------
$color = new Color('#@@@@@@', 'New color');
$repository->add($color);
$repository->find(ColorId('#@@@@@@')); //should hit cache and return an instance of Color.

Quality

To run the PHPUnit tests at the command line, go to the tests directory and issue phpunit., (*6)

This library attempts to comply with PSR-1, PSR-2, PSR-4., (*7)

If you notice compliance oversights, please send a patch via Pull Request., (*8)

Contribute

Contributions to the package are always welcome!, (*9)

Support

Get in touch with me using one of the following means:, (*10)

Authors

License

The code base is licensed under the MIT license., (*11)

The Versions

09/08 2016

dev-master

9999999-dev http://nilportugues.com

Implementation of a base repository with cache layer using StashPHP

  Sources   Download

MIT

The Requires

 

The Development Requires

by Nil Portugués

repository cache pagination ddd hexagonal adapters nil portugues nilportugues ports and adapters ports pageable

09/08 2016

3.0.2

3.0.2.0 http://nilportugues.com

Implementation of a base repository with cache layer using StashPHP

  Sources   Download

MIT

The Requires

 

The Development Requires

by Nil Portugués

repository cache pagination ddd hexagonal adapters nil portugues nilportugues ports and adapters ports pageable

09/08 2016

3.0.1

3.0.1.0 http://nilportugues.com

Implementation of a base repository with cache layer using StashPHP

  Sources   Download

MIT

The Requires

 

The Development Requires

by Nil Portugués

repository cache pagination ddd hexagonal adapters nil portugues nilportugues ports and adapters ports pageable

09/08 2016

3.0.0

3.0.0.0 http://nilportugues.com

Implementation of a base repository with cache layer using StashPHP

  Sources   Download

MIT

The Requires

 

The Development Requires

by Nil Portugués

repository cache pagination ddd hexagonal adapters nil portugues nilportugues ports and adapters ports pageable

05/05 2016

2.2.1

2.2.1.0 http://nilportugues.com

Implementation of a base repository with cache layer using StashPHP

  Sources   Download

MIT

The Requires

 

The Development Requires

by Nil Portugués

repository cache pagination ddd hexagonal adapters nil portugues nilportugues ports and adapters ports pageable

18/03 2016

2.2.0

2.2.0.0 http://nilportugues.com

Implementation of a base repository with cache layer using StashPHP

  Sources   Download

MIT

The Requires

 

The Development Requires

by Nil Portugués

repository cache pagination ddd hexagonal adapters nil portugues nilportugues ports and adapters ports pageable

18/03 2016

2.1.0

2.1.0.0 http://nilportugues.com

Implementation of a base repository with cache layer using StashPHP

  Sources   Download

MIT

The Requires

 

The Development Requires

by Nil Portugués

repository cache pagination ddd hexagonal adapters nil portugues nilportugues ports and adapters ports pageable

11/02 2016

1.0.1

1.0.1.0 http://nilportugues.com

Implementation of a base repository with cache layer using StashPHP

  Sources   Download

MIT

The Requires

 

The Development Requires

by Nil Portugués

repository cache pagination ddd hexagonal adapters nil portugues nilportugues ports and adapters ports pageable

27/01 2016

1.0.0

1.0.0.0 http://nilportugues.com

Implementation of a base repository with cache layer using StashPHP

  Sources   Download

MIT

The Requires

 

The Development Requires

by Nil Portugués

repository cache pagination ddd hexagonal adapters nil portugues nilportugues ports and adapters ports pageable