<?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($oZBhJ) { $this->clearCache(); } public function remove($oZBhJ) { $this->clearCache(); } public function total() { return count($this->all()); } private function idsPaginate(&$oZBhJ, $hpBip, $INQzX) { goto cw28l; qk91S: for ($ZJIgz = $rXzzb; $ZJIgz < $rXzzb + $INQzX; $ZJIgz++) { if (!isset($oZBhJ[$ZJIgz])) { break; } $QqyDj[] = $oZBhJ[$ZJIgz]; } goto bCNTv; bCNTv: return $QqyDj; goto QQ26N; ArA6U: $rXzzb = max($hpBip - 1, 0) * $INQzX; goto PEaCx; PEaCx: if (!isset($oZBhJ[$rXzzb])) { return array(); } goto KlEDO; KlEDO: $QqyDj = array(); goto qk91S; cw28l: $hpBip = max($hpBip, 1); goto ArA6U; QQ26N: } public function paginate($hpBip, $INQzX) { $oZBhJ = $this->all(); return $this->idsPaginate($oZBhJ, $hpBip, $INQzX); } public function paginateRandom($hpBip, $INQzX, $ISurb = 'all', $iUuvZ = 60) { $oZBhJ = Cache::remember($this->name() . '_Random_' . $ISurb, $iUuvZ, function () { $oZBhJ = $this->all(); shuffle($oZBhJ); return $oZBhJ; }); return $this->idsPaginate($oZBhJ, $hpBip, $INQzX); } public function forgetRandom($ISurb = 'all') { Cache::forget($this->name() . '_Random_' . $ISurb); } }