Refactor cache handling in VariableManager and update configuration options
Some checks are pending
CI / debug (push) Waiting to run
CI / release_executable (push) Waiting to run
CI / release (push) Waiting to run
CI / debug_executable (push) Waiting to run
CI / check-phpunit (push) Waiting to run
CI / check-phpdoc (push) Waiting to run
CI / generate-phpdoc (push) Blocked by required conditions
CI / test (push) Blocked by required conditions
CI / release-documentation (push) Blocked by required conditions
CI / release-artifacts (push) Blocked by required conditions

This commit is contained in:
netkas 2025-03-17 13:47:09 -04:00
parent bbeb388e88
commit c95cdcd4da
Signed by: netkas
GPG key ID: 4D8629441B76E4CC
5 changed files with 146 additions and 134 deletions

View file

@ -50,4 +50,5 @@
return self::$instance;
}
}

View file

@ -3,14 +3,11 @@
namespace Socialbox\Classes\CliCommands;
use Exception;
use ncc\CLI\Main;
use ncc\ThirdParty\Symfony\Process\Exception\InvalidArgumentException;
use PDOException;
use Socialbox\Abstracts\CacheLayer;
use Socialbox\Classes\Configuration;
use Socialbox\Classes\Cryptography;
use Socialbox\Classes\Database;
use Socialbox\Classes\Logger;
use Socialbox\Classes\Resources;
use Socialbox\Enums\DatabaseObjects;
use Socialbox\Exceptions\CryptographyException;
@ -92,7 +89,8 @@
if(Configuration::getCacheConfiguration()->isEnabled())
{
Program::getLogger()->verbose('Clearing cache layer...');
CacheLayer::getInstance()->clear();
// TODO: Re-implement cache layer
//CacheLayer::getInstance()->clear();
}
foreach(DatabaseObjects::casesOrdered() as $object)

View file

@ -4,7 +4,7 @@ namespace Socialbox\Managers;
use PDO;
use PDOException;
use Socialbox\Abstracts\CacheLayer;
use Socialbox\Classes\CacheLayer;
use Socialbox\Classes\Configuration;
use Socialbox\Classes\Database;
use Socialbox\Exceptions\DatabaseOperationException;
@ -33,22 +33,23 @@ class VariableManager
{
throw new DatabaseOperationException(sprintf('Failed to set variable %s in the database', $name), $e);
}
finally
{
if(Configuration::getConfiguration()['cache']['enabled'] && Configuration::getConfiguration()['cache']['variables']['enabled'])
{
if(Configuration::getConfiguration()['cache']['variables']['max'] > 0)
{
if(CacheLayer::getInstance()->getPrefixCount('VARIABLES_') >= Configuration::getConfiguration()['cache']['variables']['max'])
{
// Return early if the cache is full
return;
}
}
// TODO: Re-implement caching
//finally
//{
//if(Configuration::getConfiguration()['cache']['enabled'] && Configuration::getConfiguration()['cache']['variables']['enabled'])
//{
// if(Configuration::getConfiguration()['cache']['variables']['max'] > 0)
// {
// if(CacheLayer::getPrefixCount('VARIABLES_') >= Configuration::getConfiguration()['cache']['variables']['max'])
// {
// // Return early if the cache is full
// return;
// }
// }
CacheLayer::getInstance()->set(sprintf("VARIABLES_%s", $name), $value, (int)Configuration::getConfiguration()['cache']['variables']['ttl']);
}
}
// CacheLayer::getInstance()->set(sprintf("VARIABLES_%s", $name), $value, (int)Configuration::getConfiguration()['cache']['variables']['ttl']);
//}
//}
}
/**

View file

@ -107,7 +107,13 @@
"default_email_address_privacy": "CONTACTS",
"default_phone_number_privacy": "CONTACTS",
"default_birthday_privacy": "PRIVATE",
"default_url_privacy": "PUBLIC"
"default_url_privacy": "PUBLIC",
"max_contact_signing_keys": 50,
"get_encryption_channel_requests_limit": 100,
"get_encryption_channels_limit": 100,
"get_encryption_channel_incoming_limit": 100,
"get_encryption_channel_outgoing_limit": 100,
"encryption_channel_max_messages": 100
},
"storage": {
"path": "/etc/socialbox",

View file

@ -107,7 +107,13 @@
"default_email_address_privacy": "CONTACTS",
"default_phone_number_privacy": "CONTACTS",
"default_birthday_privacy": "PRIVATE",
"default_url_privacy": "PUBLIC"
"default_url_privacy": "PUBLIC",
"max_contact_signing_keys": 50,
"get_encryption_channel_requests_limit": 100,
"get_encryption_channels_limit": 100,
"get_encryption_channel_incoming_limit": 100,
"get_encryption_channel_outgoing_limit": 100,
"encryption_channel_max_messages": 100
},
"storage": {
"path": "/etc/socialbox",