Add explicit Session caching

This commit is contained in:
Philipp 2021-12-13 19:40:38 +01:00
parent e7283abaa8
commit 5b5cea9335
No known key found for this signature in database
GPG key ID: 24A7501396EB5432
6 changed files with 67 additions and 36 deletions

View file

@ -22,8 +22,8 @@
namespace Friendica\Core\Session\Factory;
use Friendica\App;
use Friendica\Core\Cache\Capability\ICanCache;
use Friendica\Core\Cache\Enum;
use Friendica\Core\Cache\Factory\Cache;
use Friendica\Core\Config\Capability\IManageConfigValues;
use Friendica\Core\Session\Capability\IHandleSessions;
use Friendica\Core\Session\Type;
@ -51,14 +51,14 @@ class Session
* @param App\BaseURL $baseURL
* @param IManageConfigValues $config
* @param Database $dba
* @param ICanCache $cache
* @param Cache $cacheFactory
* @param LoggerInterface $logger
* @param Profiler $profiler
* @param array $server
*
* @return IHandleSessions
*/
public function createSession(App\Mode $mode, App\BaseURL $baseURL, IManageConfigValues $config, Database $dba, ICanCache $cache, LoggerInterface $logger, Profiler $profiler, array $server = [])
public function createSession(App\Mode $mode, App\BaseURL $baseURL, IManageConfigValues $config, Database $dba, Cache $cacheFactory, LoggerInterface $logger, Profiler $profiler, array $server = [])
{
$profiler->startRecording('session');
$session = null;
@ -75,6 +75,8 @@ class Session
$handler = new Handler\Database($dba, $logger, $server);
break;
case self::HANDLER_CACHE:
$cache = $cacheFactory->createDistributed();
// In case we're using the db as cache driver, use the native db session, not the cache
if ($config->get('system', 'cache_driver') === Enum\Type::DATABASE) {
$handler = new Handler\Database($dba, $logger, $server);