[*] исправлен метод мемкэша
This commit is contained in:
1 parent
4a11e29af5
commit
8f949fd692
1 file changed
+16
-9
@@ -62,6 +62,7 @@ class CCache
|
||||
private static $cache_enabled = true;
|
||||
|
||||
private static $lastError = '';
|
||||
|
||||
/**
|
||||
* Инициализация кэша
|
||||
*
|
||||
@@ -71,15 +72,15 @@ class CCache
|
||||
public static function init($dir, $cache_ttl, $enabled = true): void
|
||||
{
|
||||
if (!isset($dir) or empty($dir)) {
|
||||
self::$cache_dir = $dir;
|
||||
} else {
|
||||
self::$lastError = 'Incorrect cache path!';
|
||||
} else {
|
||||
self::$cache_dir = $dir;
|
||||
}
|
||||
|
||||
if (!isset($cache_ttl) or empty($cache_ttl)) {
|
||||
self::$cache_ttl = $cache_ttl;
|
||||
} else {
|
||||
self::$lastError = 'Incorrect cache TTL!';
|
||||
} else {
|
||||
self::$cache_ttl = $cache_ttl;
|
||||
}
|
||||
|
||||
self::$cache_enabled = $enabled;
|
||||
@@ -269,7 +270,8 @@ class CCache
|
||||
* @param int $port
|
||||
* @return bool
|
||||
*/
|
||||
public static function useMemcache(string $host = 'localhost', int $port = 11211):bool {
|
||||
public static function useMemcache(string $host = 'localhost', int $port = 11211): bool
|
||||
{
|
||||
self::$memcacheHost = $host;
|
||||
self::$memcachePort = $port;
|
||||
self::$memcacheObject = new Memcache;
|
||||
@@ -287,7 +289,8 @@ class CCache
|
||||
/**
|
||||
* Метод для записи в мемкэш
|
||||
*/
|
||||
private static function writeMemcache($name, $value):void {
|
||||
private static function writeMemcache($name, $value): void
|
||||
{
|
||||
self::$memcacheObject->set($name, $value, MEMCACHE_COMPRESSED, self::$cache_ttl);
|
||||
return;
|
||||
}
|
||||
@@ -295,14 +298,16 @@ class CCache
|
||||
/**
|
||||
* Метод для чтения из мемкэша
|
||||
*/
|
||||
private static function getMemcache($name) {
|
||||
private static function getMemcache($name)
|
||||
{
|
||||
return self::$memcacheObject->get($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Тестовый метод для очистки мемкэша
|
||||
*/
|
||||
private static function flushMemcache():void {
|
||||
private static function flushMemcache(): void
|
||||
{
|
||||
self::$memcacheObject->flush();
|
||||
return;
|
||||
}
|
||||
@@ -312,8 +317,10 @@ class CCache
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getLastError():string {
|
||||
public static function getLastError(): string
|
||||
{
|
||||
return self::$lastError;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in new issue
Block a user