mirror of
https://github.com/friendica/friendica
synced 2025-04-27 11:10:12 +00:00
CleanUp Cache namespace
- Introduce enum "Duration" - Introduce enum "Type" - Move "Cache\Cache" to "BaseCache"
This commit is contained in:
parent
4e83b2930e
commit
424c87195b
37 changed files with 139 additions and 118 deletions
|
@ -22,7 +22,7 @@ class CacheFactory
|
|||
/**
|
||||
* @var string The default cache if nothing set
|
||||
*/
|
||||
const DEFAULT_TYPE = Cache\Cache::TYPE_DATABASE;
|
||||
const DEFAULT_TYPE = Cache\Type::DATABASE;
|
||||
|
||||
/**
|
||||
* @var IConfiguration The IConfiguration to read parameters out of the config
|
||||
|
@ -73,16 +73,16 @@ class CacheFactory
|
|||
}
|
||||
|
||||
switch ($type) {
|
||||
case Cache\Cache::TYPE_MEMCACHE:
|
||||
case Cache\Type::MEMCACHE:
|
||||
$cache = new Cache\MemcacheCache($this->hostname, $this->config);
|
||||
break;
|
||||
case Cache\Cache::TYPE_MEMCACHED:
|
||||
case Cache\Type::MEMCACHED:
|
||||
$cache = new Cache\MemcachedCache($this->hostname, $this->config, $this->logger);
|
||||
break;
|
||||
case Cache\Cache::TYPE_REDIS:
|
||||
case Cache\Type::REDIS:
|
||||
$cache = new Cache\RedisCache($this->hostname, $this->config);
|
||||
break;
|
||||
case Cache\Cache::TYPE_APCU:
|
||||
case Cache\Type::APCU:
|
||||
$cache = new Cache\APCuCache($this->hostname);
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
namespace Friendica\Factory;
|
||||
|
||||
use Friendica\Core\Cache\Cache;
|
||||
use Friendica\Core\Cache\IMemoryCache;
|
||||
use Friendica\Core\Cache\Type;
|
||||
use Friendica\Core\Config\IConfiguration;
|
||||
use Friendica\Core\Lock;
|
||||
use Friendica\Database\Database;
|
||||
|
@ -57,10 +57,10 @@ class LockFactory
|
|||
|
||||
try {
|
||||
switch ($lock_type) {
|
||||
case Cache::TYPE_MEMCACHE:
|
||||
case Cache::TYPE_MEMCACHED:
|
||||
case Cache::TYPE_REDIS:
|
||||
case Cache::TYPE_APCU:
|
||||
case Type::MEMCACHE:
|
||||
case Type::MEMCACHED:
|
||||
case Type::REDIS:
|
||||
case Type::APCU:
|
||||
$cache = $this->cacheFactory->create($lock_type);
|
||||
if ($cache instanceof IMemoryCache) {
|
||||
return new Lock\CacheLock($cache);
|
||||
|
@ -109,7 +109,7 @@ class LockFactory
|
|||
|
||||
// 2. Try to use Cache Locking (don't use the DB-Cache Locking because it works different!)
|
||||
$cache_type = $this->config->get('system', 'cache_driver', 'database');
|
||||
if ($cache_type != Cache::TYPE_DATABASE) {
|
||||
if ($cache_type != Type::DATABASE) {
|
||||
try {
|
||||
$cache = $this->cacheFactory->create($cache_type);
|
||||
if ($cache instanceof IMemoryCache) {
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
namespace Friendica\Factory;
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\Core\Cache\Cache;
|
||||
use Friendica\Core\Cache\ICache;
|
||||
use Friendica\Core\Cache\Type;
|
||||
use Friendica\Core\Config\IConfiguration;
|
||||
use Friendica\Core\Session;
|
||||
use Friendica\Core\System;
|
||||
|
@ -55,7 +55,7 @@ class SessionFactory
|
|||
break;
|
||||
case self::HANDLER_CACHE:
|
||||
// In case we're using the db as cache driver, use the native db session, not the cache
|
||||
if ($config->get('system', 'cache_driver') === Cache::TYPE_DATABASE) {
|
||||
if ($config->get('system', 'cache_driver') === Type::DATABASE) {
|
||||
$handler = new Session\Handler\Database($dba, $logger, $server);
|
||||
} else {
|
||||
$handler = new Session\Handler\Cache($cache, $logger, $server);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue