pluf2

pluf2 Commit Details


Date:2008-11-07 16:52:59 (16 years 1 month ago)
Author:Loic d'Anterroches
Branch:master
Commit:c24dfe5824d43249bd55269f0cbd6cb8be9df374
Parents: 04e2ee104c4477f4834b0da330c0957098fd3002
Message:Added a factory controlled by the Pluf configuration file.

This allows easy switching from one cache engine to another without
affecting the code.
Changes:

File differences

src/Pluf/Cache.php
2525
2626
2727
28
28
29
30
2931
3032
3133
3234
3335
34
36
3537
3638
3739
......
4648
4749
4850
51
52
53
54
55
56
57
58
59
60
61
62
63
4964
5065
5166
* Cache class.
*
* You should not use this class directly, but one of the subclasses
* implementing a given engine.
* implementing a given engine. This is done automatically when using
* the factory. It will use the engine defined by the 'cache_engine'
* configuration variable.
*
* Default timeout in seconds is defined by the 'cache_timeout'
* configuration variable.
*
* <code>
* $cache = new Pluf_Cache_File();
* $cache = new Pluf_Cache::factory();
* if (null === ($foo=$cache->get('my-key'))) {
* $foo = run_complex_operation();
* $cache->set('my-key', $foo);
class Pluf_Cache
{
/**
* Factory.
*
* @return Pluf_Cache_* Cache object
*/
public static function factory()
{
if (false == ($engine = Pluf::f('cache_engine', false))) {
throw new Pluf_Exception_SettingError('"cache_engine" setting not defined.');
}
return new $engine();
}
/**
* Set a value in the cache.
*
* @param string Key to store the information

Archive Download the corresponding diff file

Branches

Number of commits:
Page rendered in 0.06443s using 13 queries.