From 7278be4e499e05bd8876fdf7a419c789e570f940 Mon Sep 17 00:00:00 2001 From: JaguarJack Date: Wed, 21 Oct 2020 17:23:22 +0800 Subject: [PATCH] =?UTF-8?q?add:=E6=96=B0=E5=A2=9E=E6=A8=A1=E5=9E=8B?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E7=BC=93=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- extend/catcher/CatchModelCollection.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) 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