Skip to content
This repository was archived by the owner on Dec 15, 2025. It is now read-only.
/cachePublic archive

A simple PHP Object Oriented caching layer with support for various backends

License

Notifications You must be signed in to change notification settings

AngryBytes/cache

Repository files navigation

AngryBytes Cache

This package is no longer maintained!

Build StatusScrutinizer Code Quality

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

Installation

Installation through Composer at Packagist

Usage

Usage is simple:

<?php// Instantiate$adapter = newAngryBytes\Cache\Adapter\Memcached; $adapter->addServer('localhost', 11211); $cache = newAngryBytes\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:

<?php// Load$data = $cache->load('cache-key'); // Checkif ($datainstanceofAngryBytes\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:

<?php// Two stores with same adapter but different prefix:$cache1 = newAngryBytes\Cache\Cache($adapter); $cache1->setIdPrefix('foo'); $cache2 = newAngryBytes\Cache\Cache($adapter); $cache2->setIdPrefix('foo');

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

<?php$cache = newAngryBytes\Cache\Cache($adapter); $cache->addIdPrefix('foo'); $cache->addIdPrefix('bar');

About

A simple PHP Object Oriented caching layer with support for various backends

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •