public static function Dispose($cache_name, $options = array()) { unset($options["save_on_destruction"]); $mc = new self($cache_name, $options); if (!$mc->is_dirty()) { return; } $mc->connect(); if (!($res = $mc->mem_cache_instace->replace($mc->genKey(), $mc->get_internal_cache()))) { $res = $mc->mem_cache_instace->set($mc->genKey(), $mc->get_internal_cache()); } if ($mc->mem_cache_instace->get($mc->genKey()) != $mc->get_internal_cache()) { $mc->disconnect(); throw new \Exception("It seems race condition happened on saving cache updates, updates not saved!"); } $mc->disconnect(); }