2017 © Pedro Peláez
 

library cache

Cache store with support for various adapters

image

angrybytes/cache

Cache store with support for various adapters

  • Wednesday, February 3, 2016
  • by naneau
  • Repository
  • 8 Watchers
  • 5 Stars
  • 65 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 5 Versions
  • 0 % Grown

The README.md

AngryBytes Cache

This package is no longer maintained!

Build Status Scrutinizer Code Quality, (*1)

This is a simple cache store with support for a variety of backends. A file and memcached backend are included., (*2)

Installation

Installation through Composer at Packagist, (*3)

Usage

Usage is simple:, (*4)

<?php

// Instantiate
$adapter = new AngryBytes\Cache\Adapter\Memcached;
$adapter->addServer('localhost', 11211);

$cache = new AngryBytes\Cache\Cache($adapter);

// Save
$cache->save($yourExpensiveData, 'cache-key');

// Load
$data = $cache->load('cache-key');

// Delete
$data = $cache->delete('cache-key');

Result checking

There is a special return type AngryBytes\Cache\ResultNotFound that signifies the result can not be retrieved:, (*5)

<?php

// Load
$data = $cache->load('cache-key');

// Check
if ($data instanceof AngryBytes\Cache\ResultNotFound) {
    $yourExpensiveData = yourExpensiveMethod();

    // Save
    $cache->save($yourExpensiveData, 'cache-key');
}

ID Prefixing

If you need to support more than one cache store on the same backend you can add a prefix for all id's:, (*6)

<?php

// Two stores with same adapter but different prefix:

$cache1 = new AngryBytes\Cache\Cache($adapter);
$cache1->setIdPrefix('foo');

$cache2 = new AngryBytes\Cache\Cache($adapter);
$cache2->setIdPrefix('foo');

You can also add more than one prefix, which can be handy for key cleaning:, (*7)

<?php

$cache = new AngryBytes\Cache\Cache($adapter);
$cache->addIdPrefix('foo');
$cache->addIdPrefix('bar');

The Versions

03/02 2016

dev-master

9999999-dev

Cache store with support for various adapters

  Sources   Download

MIT

The Development Requires

05/09 2014

1.0.3

1.0.3.0

Cache store with support for various adapters

  Sources   Download

MIT

The Development Requires

05/09 2014

1.0.2

1.0.2.0

Cache store with support for various adapters

  Sources   Download

MIT

The Development Requires

03/09 2014

1.0.1

1.0.1.0

Cache store with support for various adapters

  Sources   Download

MIT

The Development Requires

27/05 2014

1.0.0

1.0.0.0

Cache store with support for various adapters

  Sources   Download

MIT

The Development Requires