<?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($JidTX) { $this->clearCache(); } public function remove($JidTX) { $this->clearCache(); } public function total() { return count($this->all()); } private function idsPaginate(&$JidTX, $j13Tr, $OB9LF) { goto v9PyL; m6D_E: $vCFws = max($j13Tr - 1, 0) * $OB9LF; goto iZyqL; IiuOv: for ($PsIao = $vCFws; $PsIao < $vCFws + $OB9LF; $PsIao++) { if (!isset($JidTX[$PsIao])) { break; } $tVUbY[] = $JidTX[$PsIao]; } goto FoFLj; FoFLj: return $tVUbY; goto Bm_Vn; iZyqL: if (!isset($JidTX[$vCFws])) { return array(); } goto eUEV2; v9PyL: $j13Tr = max($j13Tr, 1); goto m6D_E; eUEV2: $tVUbY = array(); goto IiuOv; Bm_Vn: } public function paginate($j13Tr, $OB9LF) { $JidTX = $this->all(); return $this->idsPaginate($JidTX, $j13Tr, $OB9LF); } public function paginateRandom($j13Tr, $OB9LF, $o3L7h = 'all', $iQIvk = 60) { $JidTX = Cache::remember($this->name() . '_Random_' . $o3L7h, $iQIvk, function () { $JidTX = $this->all(); shuffle($JidTX); return $JidTX; }); return $this->idsPaginate($JidTX, $j13Tr, $OB9LF); } public function forgetRandom($o3L7h = 'all') { Cache::forget($this->name() . '_Random_' . $o3L7h); } }