| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- <?php
- class Core_Cache {
- var $cache;
- public function __construct() {
- $this->cache = array();
- }
- public static function &getInstance() {
- static $_instance;
- if (!is_object($_instance)) {
- $_instance = new Core_Cache();
- }
- return $_instance;
- }
- public static function get($key, $default = null) {
- return self::getInstance()->_get($key, $default);
- }
- public static function get_and_clean($key, $default = null) {
- return self::getInstance()->_get_and_clean($key, $default);
- }
- public static function set($key, $value) {
- return self::getInstance()->_set($key, $value);
- }
- public function &_get($key, $default = null) {
- $null = null;
- if ($key === null) return $null;
- if (array_key_exists($key, $this->cache)) {
- return $this->cache[$key];
- } else {
- return $default;
- }
- }
- public function &_get_and_clean($key, $default = null) {
- if (array_key_exists($key, $this->cache)) {
- $ret = $this->cache[$key];
- unset($this->cache[$key]);
- return $ret;
- } else {
- return $default;
- }
- }
- public function _set($key, $value) {
- $this->cache[$key] = $value;
- return true;
- }
- public function dbg() {
- return self::_('dbg','all','values');
- }
- }
|