/** * Refresh the data cache * * @return void */ static function refreshDataCache() { $mutex = new CMbFileMutex("config-build"); $mutex->acquire(20); // If cache was built by another thread if (self::getValuesCacheStatus() === self::STATUS_OK) { $mutex->release(); $hosts_shm = SHM::get("config-values-__HOSTS__"); $hosts = $hosts_shm["content"]; $values = array(); foreach ($hosts as $_host) { $_host_value = SHM::get("config-values-{$_host}"); $values[$_host] = $_host_value["content"]; } self::$values = $values; self::$hosts = $hosts; self::$dirty = false; mbLog("'config-values' already present, skipping regeneration"); return; } $t = microtime(true); self::buildAllConfig(); $t1 = microtime(true) - $t; $datetime = strftime(CMbDT::ISO_DATETIME); foreach (self::$values as $_host => $_configs) { SHM::put("config-values-{$_host}", array("date" => $datetime, "content" => $_configs)); } SHM::put("config-values-__HOSTS__", array("date" => $datetime, "content" => array_keys(self::$values))); $t2 = microtime(true) - $t - $t1; mbLog(sprintf("'config-values' gerenated in %f ms, written in %f ms", $t1 * 1000, $t2 * 1000)); $mutex->release(); self::$dirty = false; }