I am searching for a solution to code cache independent PHP code.
Some kind of Class or Library that provides a cache independent Layer.
So i can start coding and use a file based cache on the beginning and switch to apc/eaccellerator/memcached when the projects load goes up.
I know, thats not hard to code on your own, but thats also the reason why i believe that something like this already exists. And i would prefer using an already tested solution :)
Thanks in advance for you input!
Edit: Sorry guys, but i need a standalone library which should play along nice with existing structures.
That of FluxBB: https://github.com/fluxbb/cache
This kind of solutions should exist in pretty much any PHP Framework.
For a couple of examples
Zend_Cache
: switching from one backend to another is just a matter of configuration.CodeIgniter has a good cache driver.
Why not create your own cache system, its not really that complex, just have a structure to load drivers, have an API Interface to implement and you should be good
class PHPCache
{
protected $Driver;
public function __construct($driver)
{
require_once 'drivers/' . $drivers . '.driver.php';
$driver = "PHPCacheDriver_" . $driver;
$this->Driver = new $driver;
}
public function create($key,$value)
{
return $this->Driver->create($key,$value);
}
public function read($key,$value)
{
return $this->Driver->read($key,$value);
}
public function update($key,$value)
{
return $this->Driver->update($key,$value);
}
public function remove($key)
{
return $this->Driver->remove($key);
}
}
And then each driver implement an interface and CRUD the data accordingly.
PEAR has the Cache package, which has containers for:
PEAR's Cache_Lite uses files only.