add:新增模型数据缓存
This commit is contained in:
parent
a62020650c
commit
7278be4e49
@ -4,6 +4,7 @@ namespace catcher;
|
|||||||
use catcher\library\excel\CatchExcel;
|
use catcher\library\excel\CatchExcel;
|
||||||
use catcher\library\excel\Excel;
|
use catcher\library\excel\Excel;
|
||||||
use catcher\library\excel\ExcelContract;
|
use catcher\library\excel\ExcelContract;
|
||||||
|
use think\facade\Cache;
|
||||||
use think\model\Collection;
|
use think\model\Collection;
|
||||||
|
|
||||||
class CatchModelCollection extends Collection
|
class CatchModelCollection extends Collection
|
||||||
@ -67,4 +68,19 @@ class CatchModelCollection extends Collection
|
|||||||
|
|
||||||
return (new Excel)->save($excel, $path, $disk);
|
return (new Excel)->save($excel, $path, $disk);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 缓存 collection
|
||||||
|
*
|
||||||
|
* @time 2020年10月21日
|
||||||
|
* @param $key
|
||||||
|
* @param int $ttl
|
||||||
|
* @param string $store
|
||||||
|
* @return bool
|
||||||
|
* @throws \Psr\SimpleCache\InvalidArgumentException
|
||||||
|
*/
|
||||||
|
public function cache($key, int $ttl = 0, string $store = 'redis')
|
||||||
|
{
|
||||||
|
return Cache::store($store)->set($key, $this->items, $ttl);
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user