hotfix CCache and enable use cache
This commit is contained in:
1 parent
d5bdfbc33c
commit
1e7ba3faa6
2 files changed
+10
-7
No files matched your search
@@ -189,8 +189,15 @@ function getClientInfo() {
|
|||||||
* @return array|bool
|
* @return array|bool
|
||||||
*/
|
*/
|
||||||
function getUserDevices($userId) {
|
function getUserDevices($userId) {
|
||||||
|
$cacheId = md5('getUserDevices_'.$userId);
|
||||||
|
if(CCache::checkCache($cacheId)){
|
||||||
|
$res = CCache::getCache($cacheId);
|
||||||
|
} else {
|
||||||
global $DB;
|
global $DB;
|
||||||
$res = $DB->query('SELECT * FROM devices WHERE user="'.$userId.'"');
|
$res = $DB->query('SELECT * FROM devices WHERE user="'.$userId.'"');
|
||||||
|
CCache::writeCache($cacheId, $res);
|
||||||
|
}
|
||||||
|
|
||||||
if($res){
|
if($res){
|
||||||
return $res;
|
return $res;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -86,17 +86,13 @@ class CCache
|
|||||||
* Получение кэшированых данных из кэша
|
* Получение кэшированых данных из кэша
|
||||||
*
|
*
|
||||||
* @param string $name Имя элемента кэша
|
* @param string $name Имя элемента кэша
|
||||||
* @return false|mixed Кэшированные данные
|
* @return mixed Кэшированные данные
|
||||||
*/
|
*/
|
||||||
public static function getCache($name)
|
public static function getCache(string $name)
|
||||||
{ // Получить элемент из кэша
|
{
|
||||||
self::$quantity++;
|
self::$quantity++;
|
||||||
self::$quantity_read++;
|
self::$quantity_read++;
|
||||||
if (self::checkCache($name)) {
|
|
||||||
return unserialize(base64_decode(file_get_contents(self::$cache_dir . md5($name) . '.tmp')));
|
return unserialize(base64_decode(file_get_contents(self::$cache_dir . md5($name) . '.tmp')));
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in new issue
Block a user