1
1
Fork 0

codeblock updates

This commit is contained in:
Philipp Holzer 2019-02-05 23:42:49 +01:00
parent d9e38be4df
commit 62c79e1c4f
No known key found for this signature in database
GPG key ID: 517BE60E2CE5C8A5
6 changed files with 54 additions and 31 deletions

View file

@ -9,10 +9,7 @@ namespace Friendica\Core\Config;
interface IConfigAdapter interface IConfigAdapter
{ {
/** /**
* @brief Loads all configuration values into a cached storage. * Loads all configuration values into a cached storage.
*
* All configuration values of the system are stored in global cache
* which is available under the global variable Config::$config
* *
* @param string $cat The category of the configuration values to load * @param string $cat The category of the configuration values to load
* *
@ -21,17 +18,9 @@ interface IConfigAdapter
public function load($cat = "config"); public function load($cat = "config");
/** /**
* @brief Get a particular user's config variable given the category name * Get a particular user's config variable given the category name
* ($family) and a key. * ($family) and a key.
* *
* Get a particular config value from the given category ($family)
* and the $key from a cached storage in static::$config[$uid].
* $instore is only used by the set_config function
* to determine if the key already exists in the DB
* If a key is found in the DB but doesn't exist in
* local config cache, pull it into the cache so we don't have
* to hit the DB again for this item.
*
* @param string $cat The category of the configuration value * @param string $cat The category of the configuration value
* @param string $k The configuration key to query * @param string $k The configuration key to query
* @param mixed $default_value optional, The value to return if key is not set (default: null) * @param mixed $default_value optional, The value to return if key is not set (default: null)
@ -42,8 +31,6 @@ interface IConfigAdapter
public function get($cat, $k, $default_value = null, $refresh = false); public function get($cat, $k, $default_value = null, $refresh = false);
/** /**
* @brief Sets a configuration value for system config
*
* Stores a config value ($value) in the category ($family) under the key ($key) * Stores a config value ($value) in the category ($family) under the key ($key)
* for the user_id $uid. * for the user_id $uid.
* *
@ -58,9 +45,7 @@ interface IConfigAdapter
public function set($cat, $k, $value); public function set($cat, $k, $value);
/** /**
* @brief Deletes the given key from the system configuration. * Removes the configured value from the stored cache
*
* Removes the configured value from the stored cache in Config::$config
* and removes it from the database. * and removes it from the database.
* *
* @param string $cat The category of the configuration value * @param string $cat The category of the configuration value

View file

@ -15,10 +15,7 @@ namespace Friendica\Core\Config;
interface IPConfigAdapter interface IPConfigAdapter
{ {
/** /**
* @brief Loads all configuration values of a user's config family into a cached storage. * Loads all configuration values of a user's config family into a cached storage.
*
* All configuration values of the given user are stored in global cache
* which is available under the global variable self::$config[$uid].
* *
* @param string $uid The user_id * @param string $uid The user_id
* @param string $cat The category of the configuration value * @param string $cat The category of the configuration value
@ -28,12 +25,9 @@ interface IPConfigAdapter
public function load($uid, $cat); public function load($uid, $cat);
/** /**
* @brief Get a particular user's config variable given the category name * Get a particular user's config variable given the category name
* ($family) and a key. * ($family) and a key.
* *
* Get a particular user's config value from the given category ($family)
* and the $key from a cached storage in self::$config[$uid].
*
* @param string $uid The user_id * @param string $uid The user_id
* @param string $cat The category of the configuration value * @param string $cat The category of the configuration value
* @param string $k The configuration key to query * @param string $k The configuration key to query
@ -45,8 +39,6 @@ interface IPConfigAdapter
public function get($uid, $cat, $k, $default_value = null, $refresh = false); public function get($uid, $cat, $k, $default_value = null, $refresh = false);
/** /**
* @brief Sets a configuration value for a user
*
* Stores a config value ($value) in the category ($family) under the key ($key) * Stores a config value ($value) in the category ($family) under the key ($key)
* for the user_id $uid. * for the user_id $uid.
* *
@ -62,9 +54,7 @@ interface IPConfigAdapter
public function set($uid, $cat, $k, $value); public function set($uid, $cat, $k, $value);
/** /**
* @brief Deletes the given key from the users's configuration. * Removes the configured value from the stored cache
*
* Removes the configured value from the stored cache in self::$config[$uid]
* and removes it from the database. * and removes it from the database.
* *
* @param string $uid The user_id * @param string $uid The user_id

View file

@ -28,6 +28,9 @@ class JITConfigAdapter implements IConfigAdapter
$this->configCache = $configCache; $this->configCache = $configCache;
} }
/**
* {@inheritdoc}
*/
public function load($cat = "config") public function load($cat = "config")
{ {
// We don't preload "system" anymore. // We don't preload "system" anymore.
@ -50,6 +53,9 @@ class JITConfigAdapter implements IConfigAdapter
DBA::close($configs); DBA::close($configs);
} }
/**
* {@inheritdoc}
*/
public function get($cat, $k, $default_value = null, $refresh = false) public function get($cat, $k, $default_value = null, $refresh = false)
{ {
if (!$refresh) { if (!$refresh) {
@ -92,6 +98,9 @@ class JITConfigAdapter implements IConfigAdapter
return $default_value; return $default_value;
} }
/**
* {@inheritdoc}
*/
public function set($cat, $k, $value) public function set($cat, $k, $value)
{ {
// We store our setting values in a string variable. // We store our setting values in a string variable.
@ -129,6 +138,9 @@ class JITConfigAdapter implements IConfigAdapter
return $result; return $result;
} }
/**
* {@inheritdoc}
*/
public function delete($cat, $k) public function delete($cat, $k)
{ {
if (isset($this->cache[$cat][$k])) { if (isset($this->cache[$cat][$k])) {

View file

@ -28,6 +28,9 @@ class JITPConfigAdapter implements IPConfigAdapter
$this->configCache = $configCache; $this->configCache = $configCache;
} }
/**
* {@inheritdoc}
*/
public function load($uid, $cat) public function load($uid, $cat)
{ {
$pconfigs = DBA::select('pconfig', ['v', 'k'], ['cat' => $cat, 'uid' => $uid]); $pconfigs = DBA::select('pconfig', ['v', 'k'], ['cat' => $cat, 'uid' => $uid]);
@ -46,6 +49,9 @@ class JITPConfigAdapter implements IPConfigAdapter
DBA::close($pconfigs); DBA::close($pconfigs);
} }
/**
* {@inheritdoc}
*/
public function get($uid, $cat, $k, $default_value = null, $refresh = false) public function get($uid, $cat, $k, $default_value = null, $refresh = false)
{ {
if (!$refresh) { if (!$refresh) {
@ -82,6 +88,9 @@ class JITPConfigAdapter implements IPConfigAdapter
} }
} }
/**
* {@inheritdoc}
*/
public function set($uid, $cat, $k, $value) public function set($uid, $cat, $k, $value)
{ {
// We store our setting values in a string variable. // We store our setting values in a string variable.
@ -109,6 +118,9 @@ class JITPConfigAdapter implements IPConfigAdapter
return $result; return $result;
} }
/**
* {@inheritdoc}
*/
public function delete($uid, $cat, $k) public function delete($uid, $cat, $k)
{ {
$this->configCache->deleteP($uid, $cat, $k); $this->configCache->deleteP($uid, $cat, $k);

View file

@ -30,6 +30,9 @@ class PreloadConfigAdapter implements IConfigAdapter
$this->load(); $this->load();
} }
/**
* {@inheritdoc}
*/
public function load($family = 'config') public function load($family = 'config')
{ {
if ($this->config_loaded) { if ($this->config_loaded) {
@ -45,6 +48,9 @@ class PreloadConfigAdapter implements IConfigAdapter
$this->config_loaded = true; $this->config_loaded = true;
} }
/**
* {@inheritdoc}
*/
public function get($cat, $k, $default_value = null, $refresh = false) public function get($cat, $k, $default_value = null, $refresh = false)
{ {
if ($refresh) { if ($refresh) {
@ -59,6 +65,9 @@ class PreloadConfigAdapter implements IConfigAdapter
return $return; return $return;
} }
/**
* {@inheritdoc}
*/
public function set($cat, $k, $value) public function set($cat, $k, $value)
{ {
// We store our setting values as strings. // We store our setting values as strings.
@ -83,6 +92,9 @@ class PreloadConfigAdapter implements IConfigAdapter
return true; return true;
} }
/**
* {@inheritdoc}
*/
public function delete($cat, $k) public function delete($cat, $k)
{ {
$this->configCache->delete($cat, $k); $this->configCache->delete($cat, $k);

View file

@ -34,6 +34,9 @@ class PreloadPConfigAdapter implements IPConfigAdapter
} }
} }
/**
* {@inheritdoc}
*/
public function load($uid, $family) public function load($uid, $family)
{ {
if ($this->config_loaded) { if ($this->config_loaded) {
@ -53,6 +56,9 @@ class PreloadPConfigAdapter implements IPConfigAdapter
$this->config_loaded = true; $this->config_loaded = true;
} }
/**
* {@inheritdoc}
*/
public function get($uid, $cat, $k, $default_value = null, $refresh = false) public function get($uid, $cat, $k, $default_value = null, $refresh = false)
{ {
if (!$this->config_loaded) { if (!$this->config_loaded) {
@ -71,6 +77,9 @@ class PreloadPConfigAdapter implements IPConfigAdapter
return $this->configCache->getP($uid, $cat, $k, $default_value);; return $this->configCache->getP($uid, $cat, $k, $default_value);;
} }
/**
* {@inheritdoc}
*/
public function set($uid, $cat, $k, $value) public function set($uid, $cat, $k, $value)
{ {
if (!$this->config_loaded) { if (!$this->config_loaded) {
@ -98,6 +107,9 @@ class PreloadPConfigAdapter implements IPConfigAdapter
return true; return true;
} }
/**
* {@inheritdoc}
*/
public function delete($uid, $cat, $k) public function delete($uid, $cat, $k)
{ {
if (!$this->config_loaded) { if (!$this->config_loaded) {