deduplicate logic

This commit is contained in:
El RIDO
2025-10-12 18:39:36 +02:00
parent 60bab2badb
commit d76796adf3
+13 -19
View File
@@ -267,31 +267,25 @@ class Filesystem extends AbstractData
*/ */
public function setValue($value, $namespace, $key = '') public function setValue($value, $namespace, $key = '')
{ {
$file = $this->_path . DIRECTORY_SEPARATOR . $namespace . '.php';
if (function_exists('opcache_invalidate')) {
opcache_invalidate($file);
}
switch ($namespace) { switch ($namespace) {
case 'purge_limiter': case 'purge_limiter':
if (function_exists('opcache_invalidate')) { $content = '<?php' . PHP_EOL . '$GLOBALS[\'purge_limiter\'] = ' . var_export($value, true) . ';';
opcache_invalidate($this->_path . DIRECTORY_SEPARATOR . 'purge_limiter.php'); break;
}
return $this->_storeString(
$this->_path . DIRECTORY_SEPARATOR . 'purge_limiter.php',
'<?php' . PHP_EOL . '$GLOBALS[\'purge_limiter\'] = ' . var_export($value, true) . ';'
);
case 'salt': case 'salt':
return $this->_storeString( $content = '<?php # |' . $value . '|';
$this->_path . DIRECTORY_SEPARATOR . 'salt.php', break;
'<?php # |' . $value . '|'
);
case 'traffic_limiter': case 'traffic_limiter':
$this->_last_cache[$key] = $value; $this->_last_cache[$key] = $value;
if (function_exists('opcache_invalidate')) { $content = '<?php' . PHP_EOL . '$GLOBALS[\'traffic_limiter\'] = ' . var_export($this->_last_cache, true) . ';';
opcache_invalidate($this->_path . DIRECTORY_SEPARATOR . 'traffic_limiter.php'); break;
} default:
return $this->_storeString( return false;
$this->_path . DIRECTORY_SEPARATOR . 'traffic_limiter.php',
'<?php' . PHP_EOL . '$GLOBALS[\'traffic_limiter\'] = ' . var_export($this->_last_cache, true) . ';'
);
} }
return false; return $this->_storeString($file, $content);
} }
/** /**