wallet tron transactions
This commit is contained in:
@ -30,12 +30,17 @@ abstract class BaseCache
|
||||
$sCacheKey = $this->getPrimaryKey();
|
||||
$aData = $this->loadData();
|
||||
if (empty($aData)) return false;
|
||||
return Cache::put($sCacheKey, serialize($aData), self::CACHE_TTL);
|
||||
return Cache::put($sCacheKey, $aData, self::CACHE_TTL);
|
||||
}
|
||||
|
||||
abstract function loadData(): array|null;
|
||||
abstract function loadData(): array|string|null;
|
||||
|
||||
function getCacheData($primary_key = null): array|null
|
||||
function get($key): array|string|null
|
||||
{
|
||||
return $this->getCacheData($key);
|
||||
}
|
||||
|
||||
function getCacheData($primary_key = null): array|string|null
|
||||
{
|
||||
if ($primary_key === null) $primary_key = $this->primary_key;
|
||||
if (empty($primary_key)) return [];
|
||||
@ -43,10 +48,10 @@ abstract class BaseCache
|
||||
$sData = Cache::get($sCacheKey);
|
||||
if (empty($sData)) {
|
||||
$this->primary_key = $primary_key;
|
||||
if($this->loadToCache()) $sData = Cache::get($sCacheKey);
|
||||
if ($this->loadToCache()) $sData = Cache::get($sCacheKey);
|
||||
}
|
||||
if (empty($sData)) return null;
|
||||
return unserialize($sData);
|
||||
return $sData;
|
||||
}
|
||||
|
||||
//根据primary_key获取缓存数据单个值,不指定key就默认获取所有
|
||||
@ -55,7 +60,7 @@ abstract class BaseCache
|
||||
if ($primary_key === null) $primary_key = $this->primary_key;
|
||||
if (empty($primary_key)) return false;
|
||||
$aData = $this->getCacheData($primary_key);
|
||||
if(empty($aData)) return null;
|
||||
if (empty($aData)) return null;
|
||||
if (empty($key)) return $aData;
|
||||
return $aData[$key] ?? '';
|
||||
}
|
||||
@ -68,4 +73,10 @@ abstract class BaseCache
|
||||
return Cache::forget($sCacheKey);
|
||||
}
|
||||
|
||||
function clearAll(): bool
|
||||
{
|
||||
if (empty($this->primary_prefix)) return false;
|
||||
return Cache::forget($this->primary_prefix);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user