31 lines
550 B
PHP
31 lines
550 B
PHP
<?php
|
|
|
|
class mfValuecache {
|
|
public static $instance;
|
|
public $cache = [];
|
|
|
|
private function __construct() { }
|
|
|
|
public static function singleton() {
|
|
if(!isset(self::$instance)) {
|
|
$c=__CLASS__;
|
|
self::$instance=new $c();
|
|
}
|
|
return self::$instance;
|
|
}
|
|
|
|
public function get($key) {
|
|
if(array_key_exists($key, $this->cache)) {
|
|
return $this->cache[$key];
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public function set($key, $value) {
|
|
$this->cache[$key] = $value;
|
|
}
|
|
|
|
public function getCache() {
|
|
return $this->cache;
|
|
}
|
|
} |