mirror of
https://github.com/friendica/friendica
synced 2025-04-25 02:30:11 +00:00
Add explicit Session caching
This commit is contained in:
parent
e7283abaa8
commit
5b5cea9335
6 changed files with 67 additions and 36 deletions
|
@ -81,7 +81,7 @@ class Cache
|
|||
}
|
||||
|
||||
/**
|
||||
* This method creates a CacheDriver for the given cache driver name
|
||||
* This method creates a CacheDriver for distributed caching with the given cache driver name
|
||||
*
|
||||
* @param string|null $type The cache type to create (default is per config)
|
||||
*
|
||||
|
@ -90,12 +90,42 @@ class Cache
|
|||
* @throws InvalidCacheDriverException In case the underlying cache driver isn't valid or not configured properly
|
||||
* @throws CachePersistenceException In case the underlying cache has errors during persistence
|
||||
*/
|
||||
public function create(string $type = null): ICanCache
|
||||
public function createDistributed(string $type = null): ICanCache
|
||||
{
|
||||
if (empty($type)) {
|
||||
$type = $this->config->get('system', 'cache_driver', self::DEFAULT_TYPE);
|
||||
if ($type === Enum\Type::APCU) {
|
||||
throw new InvalidCacheDriverException('apcu doesn\'t support distributed caching.');
|
||||
}
|
||||
|
||||
return $this->create($type ?? $this->config->get('system', 'distributed_cache_driver', self::DEFAULT_TYPE));
|
||||
}
|
||||
|
||||
/**
|
||||
* This method creates a CacheDriver for local caching with the given cache driver name
|
||||
*
|
||||
* @param string|null $type The cache type to create (default is per config)
|
||||
*
|
||||
* @return ICanCache The instance of the CacheDriver
|
||||
*
|
||||
* @throws InvalidCacheDriverException In case the underlying cache driver isn't valid or not configured properly
|
||||
* @throws CachePersistenceException In case the underlying cache has errors during persistence
|
||||
*/
|
||||
public function createLocal(string $type = null): ICanCache
|
||||
{
|
||||
return $this->create($type ?? $this->config->get('system', 'cache_driver', self::DEFAULT_TYPE));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new Cache instance
|
||||
*
|
||||
* @param string $type The type of cache
|
||||
*
|
||||
* @return ICanCache
|
||||
*
|
||||
* @throws InvalidCacheDriverException In case the underlying cache driver isn't valid or not configured properly
|
||||
* @throws CachePersistenceException In case the underlying cache has errors during persistence
|
||||
*/
|
||||
protected function create(string $type): ICanCache
|
||||
{
|
||||
switch ($type) {
|
||||
case Enum\Type::MEMCACHE:
|
||||
$cache = new Type\MemcacheCache($this->hostname, $this->config);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue