<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace Module\Vendor\Provider\IDManager; use Illuminate\Support\Facades\Cache; abstract class AbstractDbCacheIDManager extends AbstractIDManager { public abstract function dbCacheAll(); private function clearCache() { Cache::forget($this->name() . '_All'); } public function all() { return Cache::rememberForever($this->name() . '_All', function () { return $this->dbCacheAll(); }); } public function add($FN9bz) { $this->clearCache(); } public function remove($FN9bz) { $this->clearCache(); } public function total() { return count($this->all()); } private function idsPaginate(&$FN9bz, $iXUoW, $VUK_X) { goto e_tli; NZxAB: for ($i0YzC = $KNdHj; $i0YzC < $KNdHj + $VUK_X; $i0YzC++) { if (!isset($FN9bz[$i0YzC])) { break; } $Iwq1e[] = $FN9bz[$i0YzC]; } goto TdFQC; LM1ZN: $KNdHj = max($iXUoW - 1, 0) * $VUK_X; goto CcKxp; e_tli: $iXUoW = max($iXUoW, 1); goto LM1ZN; TdFQC: return $Iwq1e; goto HIRg_; xM4Ow: $Iwq1e = array(); goto NZxAB; CcKxp: if (!isset($FN9bz[$KNdHj])) { return array(); } goto xM4Ow; HIRg_: } public function paginate($iXUoW, $VUK_X) { $FN9bz = $this->all(); return $this->idsPaginate($FN9bz, $iXUoW, $VUK_X); } public function paginateRandom($iXUoW, $VUK_X, $amv6b = 'all', $tAVpJ = 60) { $FN9bz = Cache::remember($this->name() . '_Random_' . $amv6b, $tAVpJ, function () { $FN9bz = $this->all(); shuffle($FN9bz); return $FN9bz; }); return $this->idsPaginate($FN9bz, $iXUoW, $VUK_X); } public function forgetRandom($amv6b = 'all') { Cache::forget($this->name() . '_Random_' . $amv6b); } }