2017 © Pedro Peláez
 

library cache

image

genkgo/cache

  • Wednesday, August 23, 2017
  • by frederikbosch
  • Repository
  • 3 Watchers
  • 1 Stars
  • 4,622 Installations
  • PHP
  • 1 Dependents
  • 1 Suggesters
  • 0 Forks
  • 0 Open issues
  • 19 Versions
  • 2 % Grown

The README.md

Genkgo.Cache

PHP Cache library using mechanisms as originally proposed by Anthony Ferrara., (*1)

Credit to Anthony Ferrara.

All the credit for the cache mechanisms go to @ircmaxell. Please go and read his blog post explaining why cache should be implemented this way., (*2)

Installation

Requires PHP 5.5 or later. There are no plans to support PHP 5.4 or PHP 5.3. In case this is an obstacle for you, conversion should be no problem. The library is very small., (*3)

It is installable and autoloadable via Composer as genkgo/cache., (*4)

Quality

Scrutinizer Code Quality Code Coverage Build Status, (*5)

To run the unit tests at the command line, issue phpunit -c tests/. PHPUnit is required., (*6)

This library attempts to comply with PSR-1, PSR-2, and PSR-4. If you notice compliance oversights, please send a patch via pull request., (*7)

Getting Started

Create your own adapter

Create an adapter that implements the CacheAdapterInterface. A simple array adapter would look as follows. The array adapter is also shipped with this library., (*8)

<?php
namespace My\Namespace;

use Genkgo\Cache\CacheAdapterInterface;

class ArrayAdapter implements CacheAdapterInterface
{
    private $data = [];

    public function set($key, $value)
    {
        $this->data[$key] = $value;
    }

    public function get($key)
    {
        if ($this->exists($key)) {
            return $this->data[$key];
        }
    }

    public function delete($key)
    {
        if ($this->exists($key)) {
            unset($this->data[$key]);
        }
    }

    private function exists($key)
    {
        return isset($this->data[$key]) || array_key_exists($key, $this->data);
    }
}

Inject the adapter

To use your adapter, inject it into another object and start using the api. If you do not want any cache, but your class relies on a cache adapter being there, inject the NullAdapter., (*9)

Contributing

  • Found a bug? Please try to solve it yourself first and issue a pull request. If you are not able to fix it, at least give a clear description what goes wrong. We will have a look when there is time.
  • Want to see a feature added, issue a pull request and see what happens. You could also file a bug of the missing feature and we can discuss how to implement it.

The Versions

19/10 2015
30/03 2015
30/03 2015
02/03 2015
22/01 2015

0.1.1

0.1.1.0

  Sources   Download

The Requires

  • php >=5.5

 

The Development Requires

22/01 2015

0.1.0

0.1.0.0

  Sources   Download

The Requires

  • php >=5.5

 

The Development Requires