diff --git a/extend/catcher/CatchModelCollection.php b/extend/catcher/CatchModelCollection.php index 90d1e1d..3545132 100644 --- a/extend/catcher/CatchModelCollection.php +++ b/extend/catcher/CatchModelCollection.php @@ -4,6 +4,7 @@ namespace catcher; use catcher\library\excel\CatchExcel; use catcher\library\excel\Excel; use catcher\library\excel\ExcelContract; +use think\facade\Cache; use think\model\Collection; class CatchModelCollection extends Collection @@ -67,4 +68,19 @@ class CatchModelCollection extends Collection 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); + } } \ No newline at end of file