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