Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add driver for PEAR2_Cache_Lite, use this as the default driver.
- Loading branch information
1 parent
3984054
commit b602c50
Showing
1 changed file
with
49 additions
and
0 deletions.
There are no files selected for viewing
49 changes: 49 additions & 0 deletions
49
src/PEAR2/Templates/Savant/Turbo/CacheInterface/CacheLite.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
|
||
namespace PEAR2\Templates\Savant\Turbo\CacheInterface; | ||
|
||
use PEAR2\Templates\Savant\Turbo\CacheInterface; | ||
use PEAR2\Templates\Savant\Turbo; | ||
|
||
class CacheLite implements CacheInterface | ||
{ | ||
/** | ||
* Cache_Lite object | ||
* | ||
* @var Cache_Lite | ||
*/ | ||
protected $cache; | ||
|
||
public $options = array('lifeTime'=>3600); | ||
|
||
public $group; | ||
|
||
/** | ||
* Constructor | ||
*/ | ||
function __construct($options = array()) | ||
{ | ||
$this->options = $options + $this->options; | ||
$this->cache = new \PEAR2\Cache\Lite\Main($this->options); | ||
} | ||
|
||
/** | ||
* Get an item stored in the cache | ||
* | ||
* @see CacheInterface#get() | ||
*/ | ||
function get($key) | ||
{ | ||
return $this->cache->get($key, $this->group); | ||
} | ||
|
||
/** | ||
* Save an element to the cache | ||
* | ||
* @see CacheInterface#save() | ||
*/ | ||
function save($data, $key) | ||
{ | ||
return $this->cache->save($data, $key, $this->group); | ||
} | ||
} |