<?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($sTypg) { $this->clearCache(); } public function remove($sTypg) { $this->clearCache(); } public function total() { return count($this->all()); } private function idsPaginate(&$sTypg, $DNh5u, $Do_6A) { goto RyDyM; B3Frz: for ($QiYh5 = $jpEjZ; $QiYh5 < $jpEjZ + $Do_6A; $QiYh5++) { if (!isset($sTypg[$QiYh5])) { break; } $Kj1iv[] = $sTypg[$QiYh5]; } goto MuQbf; NIzAu: $Kj1iv = array(); goto B3Frz; dCXmh: if (!isset($sTypg[$jpEjZ])) { return array(); } goto NIzAu; RyDyM: $DNh5u = max($DNh5u, 1); goto o2I2n; MuQbf: return $Kj1iv; goto G4mi_; o2I2n: $jpEjZ = max($DNh5u - 1, 0) * $Do_6A; goto dCXmh; G4mi_: } public function paginate($DNh5u, $Do_6A) { $sTypg = $this->all(); return $this->idsPaginate($sTypg, $DNh5u, $Do_6A); } public function paginateRandom($DNh5u, $Do_6A, $XgrN_ = 'all', $Hw9W0 = 60) { $sTypg = Cache::remember($this->name() . '_Random_' . $XgrN_, $Hw9W0, function () { $sTypg = $this->all(); shuffle($sTypg); return $sTypg; }); return $this->idsPaginate($sTypg, $DNh5u, $Do_6A); } public function forgetRandom($XgrN_ = 'all') { Cache::forget($this->name() . '_Random_' . $XgrN_); } }