Re: [PHP-PEAR] Output_Cache Module
[email protected] (Ulf Wendel)
| Newsgroups | php.pear |
|---|---|
| Message-ID | <[email protected]> |
Björn Schotte wrote:
> An output cache should have the following
> features:
>
> - store data in a data container (shared
> memory, DB, ...)
Right and the design could be very much like the PHPLibs Session
implementation. One controler class that provides the user API and uses
a client/supplier class to do the storage. This way you get a generic
data / function call cache. It does not give you the output cache, but
calling ob_start() / ob_end() yourself is not that hard ;-).
class cache
public:
void cache(storage, preload, check_lifetime)
mixed cacheCall(function, class)
int cacheData(data, hash)
boolean flush([id])
boolean setLifetime([id])
...
[
private:
string generateID(hash)
]
class storage
public:
mixed get(id)
boolean save(id, data)
boolean delete(id)
boolean flush()
boolean isCached(id)
boolean isExpired(id)
[
private:
string load(id)
]
Source of a quick hack to sketch the API:
http://www.redsys.de/php/show_source.php?file=cache
Ulf