performance optimizations

This commit is contained in:
Frank Schubert
2022-02-15 23:12:19 +01:00
parent fa3dec263f
commit c189041b67
10 changed files with 72 additions and 36 deletions
+10 -11
View File
@@ -4,10 +4,7 @@ class mfValuecache {
public static $instance;
public $cache = [];
private function __construct() {
}
private function __construct() { }
public static function singleton() {
if(!isset(self::$instance)) {
@@ -17,16 +14,18 @@ class mfValuecache {
return self::$instance;
}
public static function get($key) {
$instance = self::singleton();
if(array_key_exists($key, $instance->cache)) {
return $instance->cache[$key];
public function get($key) {
if(array_key_exists($key, $this->cache)) {
return $this->cache[$key];
}
return null;
}
public static function set($key, $value) {
$instance = self::singleton();
$instance->cache[$key] = $value;
public function set($key, $value) {
$this->cache[$key] = $value;
}
public function getCache() {
return $this->cache;
}
}