code standards / simplifications

This commit is contained in:
Philipp Holzer 2018-07-05 07:59:56 +02:00
parent 19209f6826
commit 906bb25972
No known key found for this signature in database
GPG key ID: 58160D7D6AF942B6
18 changed files with 70 additions and 121 deletions

View file

@ -6,7 +6,7 @@ namespace Friendica\Core\Cache;
use Friendica\Core\Cache;
/**
* @brief Implementation of the IMemoryCacheDriver mainly for testing purpose
* Implementation of the IMemoryCacheDriver mainly for testing purpose
*
* Class ArrayCache
*
@ -80,4 +80,4 @@ class ArrayCache implements IMemoryCacheDriver
return false;
}
}
}
}

View file

@ -9,12 +9,12 @@ use Friendica\Core\Config;
*
* @package Friendica\Core\Cache
*
* @brief A basic class to generate a CacheDriver
* A basic class to generate a CacheDriver
*/
class CacheDriverFactory
{
/**
* @brief This method creates a CacheDriver for the given cache driver name
* This method creates a CacheDriver for the given cache driver name
*
* @param string $driver The name of the cache driver
* @return ICacheDriver The instance of the CacheDriver

View file

@ -12,7 +12,7 @@ use Friendica\Core\Cache;
interface ICacheDriver
{
/**
* @brief Fetches cached data according to the key
* Fetches cached data according to the key
*
* @param string $key The key to the cached data
*
@ -21,18 +21,18 @@ interface ICacheDriver
public function get($key);
/**
* @brief Stores data in the cache identified by the key. The input $value can have multiple formats.
* Stores data in the cache identified by the key. The input $value can have multiple formats.
*
* @param string $key The cache key
* @param mixed $value The value to store
* @param integer $ttl The cache lifespan, must be one of the Cache constants
* @param integer $ttl The cache lifespan, must be one of the Cache constants
*
* @return bool
*/
public function set($key, $value, $ttl = Cache::FIVE_MINUTES);
/**
* @brief Delete a key from the cache
* Delete a key from the cache
*
* @param string $key The cache key
*
@ -41,7 +41,7 @@ interface ICacheDriver
public function delete($key);
/**
* @brief Remove outdated data from the cache
* Remove outdated data from the cache
*
* @return bool
*/

View file

@ -4,7 +4,7 @@ namespace Friendica\Core\Cache;
use Friendica\Core\Cache;
/**
* @brief This interface defines methods for Memory-Caches only
* This interface defines methods for Memory-Caches only
*
* Interface IMemoryCacheDriver
*
@ -13,7 +13,7 @@ use Friendica\Core\Cache;
interface IMemoryCacheDriver extends ICacheDriver
{
/**
* @brief Sets a value if it's not already stored
* Sets a value if it's not already stored
*
* @param string $key The cache key
* @param mixed $value The old value we know from the cache
@ -23,7 +23,7 @@ interface IMemoryCacheDriver extends ICacheDriver
public function add($key, $value, $ttl = Cache::FIVE_MINUTES);
/**
* @brief Compares if the old value is set and sets the new value
* Compares if the old value is set and sets the new value
*
* @param string $key The cache key
* @param mixed $oldValue The old value we know from the cache
@ -35,11 +35,11 @@ interface IMemoryCacheDriver extends ICacheDriver
public function compareSet($key, $oldValue, $newValue, $ttl = Cache::FIVE_MINUTES);
/**
* @brief Compares if the old value is set and removes it
* Compares if the old value is set and removes it
*
* @param string $key The cache key
* @param mixed $value The old value we know and want to delete
* @return bool
*/
public function compareDelete($key, $value);
}
}

View file

@ -90,6 +90,9 @@ class MemcacheCacheDriver extends BaseObject implements IMemoryCacheDriver
return $this->memcache->delete($key);
}
/**
* (@inheritdoc)
*/
public function clear()
{
return $this->memcache->flush();

View file

@ -84,12 +84,7 @@ class RedisCacheDriver extends BaseObject implements IMemoryCacheDriver
/**
* @brief Sets a value if it's not already stored
*
* @param string $key The cache key
* @param mixed $value The old value we know from the cache
* @param int $ttl The cache lifespan, must be one of the Cache constants
* @return bool
* (@inheritdoc)
*/
public function add($key, $value, $ttl = Cache::FIVE_MINUTES)
{
@ -101,13 +96,7 @@ class RedisCacheDriver extends BaseObject implements IMemoryCacheDriver
}
/**
* @brief Compares if the old value is set and sets the new value
*
* @param string $key The cache key
* @param mixed $oldValue The old value we know
* @param mixed $newValue The new value we want to set
* @param int $ttl The cache lifespan, must be one of the Cache constants
* @return bool
* (@inheritdoc)
*/
public function compareSet($key, $oldValue, $newValue, $ttl = Cache::FIVE_MINUTES)
{
@ -133,11 +122,7 @@ class RedisCacheDriver extends BaseObject implements IMemoryCacheDriver
return false;
}
/**
* @brief Compares if the old value is set and removes it
*
* @param string $key The cache key
* @param mixed $value The old value we know and want to delete
* @return bool
* (@inheritdoc)
*/
public function compareDelete($key, $value)
{

View file

@ -7,7 +7,7 @@ use Friendica\Core\Cache;
/**
* Trait TraitCompareSetDelete
*
* @brief This Trait is to compensate non native "exclusive" sets/deletes in caches
* This Trait is to compensate non native "exclusive" sets/deletes in caches
*
* @package Friendica\Core\Cache
*/
@ -22,7 +22,7 @@ trait TraitCompareDelete
abstract public function add($key, $value, $ttl = Cache::FIVE_MINUTES);
/**
* @brief NonNative - Compares if the old value is set and removes it
* NonNative - Compares if the old value is set and removes it
*
* @param string $key The cache key
* @param mixed $value The old value we know and want to delete
@ -42,4 +42,4 @@ trait TraitCompareDelete
return false;
}
}
}
}

View file

@ -7,7 +7,7 @@ use Friendica\Core\Cache;
/**
* Trait TraitCompareSetDelete
*
* @brief This Trait is to compensate non native "exclusive" sets/deletes in caches
* This Trait is to compensate non native "exclusive" sets/deletes in caches
*
* @package Friendica\Core\Cache
*/
@ -22,7 +22,7 @@ trait TraitCompareSet
abstract public function add($key, $value, $ttl = Cache::FIVE_MINUTES);
/**
* @brief NonNative - Compares if the old value is set and sets the new value
* NonNative - Compares if the old value is set and sets the new value
*
* @param string $key The cache key
* @param mixed $oldValue The old value we know from the cache
@ -45,4 +45,4 @@ trait TraitCompareSet
return false;
}
}
}
}