2017 © Pedro Peláez
 

library cache

A PSR-6 compliant PHP caching library

image

phossa2/cache

A PSR-6 compliant PHP caching library

  • Thursday, September 29, 2016
  • by phossa2
  • Repository
  • 1 Watchers
  • 3 Stars
  • 8 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

phossa2/cache [ABANDONED]

Please use phoole/cache instead., (*1)

Build Status Code Quality Code Climate PHP 7 ready HHVM Latest Stable Version License, (*2)

phossa2/cache is a PSR-6 compliant caching library for PHP. It supports various drivers and useful features like bypass, encrypt, stampede protection etc., (*3)

It requires PHP 5.4, supports PHP 7.0+ and HHVM. It is compliant with PSR-1, PSR-2, PSR-3, PSR-4, PSR-6 and the proposed PSR-5., (*4)

Installation

Install via the composer utility., (*5)

composer require "phossa2/cache"

or add the following lines to your composer.json, (*6)

{
    "require": {
       "phossa2/cache": "2.*"
    }
}

Features

  • Fully PSR-6 compliant., (*7)

  • Support all serializable PHP datatypes., (*8)

  • Extensions included:, (*9)

    • Bypass: If sees a trigger in URL (e.g. '?nocache=true'), bypass the cache., (*10)

    • Stampede Protection: Whenever cached object's lifetime is less than a configurable time, by a configurable percentage, the cache will return false on 'isHit()' which will trigger re-generation of the object., (*11)

    • Encrypt: A simple extension to encrypt the serialized content., (*12)

    • DistributedExpiration: Even out the spikes of item misses by alter expiration time a little bit., (*13)

  • Drivers, (*14)

    • StorageDriver

    The storage driver uses phossa2/storage local or cloud storage., (*15)

    • NullDriver

    The blackhole driver, can be used as fallback driver for all other drivers., (*16)

Usage

  • Simple usage, (*17)

    /*
    * cache dir default to local sys_get_temp_dir() . '/cache'
    */
    $cache = new CachePool();
    
    $item = $cache->getItem('/data.cache');
    if (!$item->isHit()) {
      $value = calcuate_data();
      $item->set($value);
      $cache->save($item);
    }
    $data = $item->get();
    
  • Specify the driver, (*18)

    use Phossa2\Cache\Driver\StorageDriver;
    use Phossa2\Storage\Storage;
    use Phossa2\Storage\Filesystem;
    use Phossa2\Storage\Driver\LocalDriver;
    
    $driver = new StorageDriver(
      new Storage('/', new Filesystem(new LocalDriver(sys_get_temp_dir()))),
      '/cache'
    );
    
    $cache = new CachePool($driver);
    
  • Use extensions, (*19)

    /*
    * DistributedExpiration extension
    */
    use Phossa2\Cache\CachePool;
    use Phossa2\Cache\Extension\DistributedExpiration;
    
    $cache = new CachePool();
    $cache->addExtension(new DistributedExpiration());
    

Change log

Please see CHANGELOG from more information., (*20)

Testing

$ composer test

Contributing

Please see CONTRIBUTE for more information., (*21)

Dependencies

License

MIT License, (*25)

The Versions

29/09 2016

dev-master

9999999-dev https://github.com/phossa2/cache

A PSR-6 compliant PHP caching library

  Sources   Download

MIT

The Requires

 

The Development Requires

cache caching psr-6 phossa phossa2

26/08 2016

2.0.1

2.0.1.0 https://github.com/phossa2/cache

A PSR-6 compliant PHP caching library

  Sources   Download

MIT

The Requires

 

The Development Requires

cache caching psr-6 phossa

17/08 2016

2.0.0

2.0.0.0 https://github.com/phossa2/cache

A PSR-6 compliant PHP caching library

  Sources   Download

MIT

The Requires

 

The Development Requires

cache caching psr-6 phossa