PHP-Cache 1.0

PHP-Cache uses a file system as a fallback and for the 'persistent' data.

Requirements:
PHP 5.3.0 or Higher

Abstract base library to cache any data to any backend. Uses file system as a fall back and for 'persistent' data.
### Specs
* Run the "run" script in the Specs directory

### Example
use Cache\Cache;

$c = new Cache('/path/to/file/cache', array(
'prefix' => 'MyAppPrefix'
));
$c->store('anyKey', $anyData);
$c->retrieve('anyKey'); // returns $anyData !
$c->erase('anyKey');

### Actual Use-Case Example
$data = $c->retrieve('data');
if (!$data){
$data = doSomeExpensiveCalculation();
$c->store('data', $data);
}
$data; // Has expensive data!

### Or, with PHP 5.3 Style
$data = $c->retrieve('myKey', function($c, $key){
return $c->store($key, doSomeExpensiveCalculation());
});

The above function is only being executed if there is no associated data to 'myKey'. If a function gets passed like this, the 'retrieve' method returns whatever the passed in function returns. As a convenience the 'store' method returns the input (= second argument).

### Here There Be Tags

$c->store('a', 'banana banana banana', array(
'tags' => 'bananas'
));
$c->store('b', 'apple apple banana', array(
'tags' => array('apples', 'bananas')
));
$c->eraseByTag('bananas');
$c->retrieve('a'); // null

License type: MIT License
Date added: 4 years, 1 month 28 days ago | Last updated: 2 years, 8 months 28 days ago

More popular Cache

This is actually one of the most advanced image hosting script. The imagetize key features: SEO, Ads Ready, Admin

Listing Files

cpojer-php-cache-7ef6313
Specs
  • run
  • 88 Bytes
  • 08/05/2010 10:01:42
Source
Backend
  • APC.php
  • 587 Bytes
  • 08/05/2010 10:01:42
  • README.md
  • 1.3 KB
  • 08/05/2010 10:01:42
  • LICENSE
  • 1.1 KB
  • 08/05/2010 10:01:42
  • namespace
  • 5 Bytes
  • 08/05/2010 10:01:42
Hot Scripts
Sponsors