11
This commit is contained in:
@ -29,6 +29,7 @@ abstract class BaseCache
|
||||
{
|
||||
$sCacheKey = $this->getPrimaryKey();
|
||||
$aData = $this->loadData();
|
||||
|
||||
if (empty($aData)) return false;
|
||||
return Cache::put($sCacheKey, $aData, self::CACHE_TTL);
|
||||
}
|
||||
@ -46,12 +47,14 @@ abstract class BaseCache
|
||||
|
||||
function getCacheData($primary_key = null): array|string|null
|
||||
{
|
||||
|
||||
if ($primary_key === null) $primary_key = $this->primary_key;
|
||||
if (empty($primary_key)) return [];
|
||||
$sCacheKey = $this->getPrimaryKey($primary_key);
|
||||
$sData = Cache::get($sCacheKey);
|
||||
if (empty($sData)) {
|
||||
$this->primary_key = $primary_key;
|
||||
|
||||
if ($this->loadToCache()) $sData = Cache::get($sCacheKey);
|
||||
}
|
||||
if (empty($sData)) return null;
|
||||
|
||||
@ -12,13 +12,16 @@ abstract class TableBaseCache extends BaseCache
|
||||
|
||||
function loadTable(): array|string|null
|
||||
{
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
function loadData(): array|string|null
|
||||
{
|
||||
|
||||
//默认获取表数据方式
|
||||
if (!empty($table_class)) {
|
||||
|
||||
$oTable = new $this->table_class();
|
||||
//排除不需要的字段
|
||||
if (!empty($this->get_exclude_columns) && $this->get_columns != ['*']) $this->get_columns = array_diff($this->get_columns, $this->get_exclude_columns);
|
||||
|
||||
Reference in New Issue
Block a user