tag = $tag; $this->type = $type; $this->handler = Cache::store('file')->tag($tagLst); } public static function create($admin, $tag) { return new static($admin, $tag); } /** * 清除所以缓存 */ public static function clearAll() { Cache::store('file')->tag('__cache_' . config('app.app_key'))->clear(); } /** * 清除商户缓存 */ public static function clearMerchantAll() { Cache::store('file')->tag('__cache_mer_' . config('app.app_key'))->clear(); } /** * 清除平台缓存 */ public static function clearSystem() { Cache::store('file')->tag('__cache_sys_' . config('app.app_key'))->clear(); } /** * @param int $merId * 清除指定商户缓存 */ public static function clearMerchant($merId) { Cache::store('file')->tag('__cache_mer_' . config('app.app_key') . '_' . $merId)->clear(); } /** * 根据tag清除缓存 * @param $merId * @param $tag */ public static function clearByTag($merId, $tag) { Cache::store('file')->tag('__cache_tag_' . config('app.app_key') . '_' . $merId . '_' . $tag)->clear(); } public static function delete($key) { Cache::store('file')->delete($key); } /** * @param $key * @return string * 生成 key */ public function cacheKey($key) { if (is_array($key)) { $key = json_encode($key, JSON_UNESCAPED_UNICODE); } return '__sys_cache_' . config('app.app_key') . $this->type . $this->tag . $key; } /** * @param string|array $key * @param $cache * @param int $expire */ public function set($key, $cache, $expire = 3600) { $this->handler->set($this->cacheKey($key), $cache, $expire); } /** * @param string|array $key * @param null $default * @return mixed */ public function get($key, $default = null) { return $this->handler->get($this->cacheKey($key), $default); } /** * @param string|array $key * @return mixed */ public function has($key) { return $this->handler->has($this->cacheKey($key)); } /** * @param string|array $key * @param $value * @param int $expire * @return mixed */ public function remember($key, $value, $expire = 3600) { return $this->handler->remember($this->cacheKey($key), $value, $expire); } }