<?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($y2SDh) { $this->clearCache(); } public function remove($y2SDh) { $this->clearCache(); } public function total() { return count($this->all()); } private function idsPaginate(&$y2SDh, $mQ9Jw, $UcEVj) { goto lZ3Nc; lZ3Nc: $mQ9Jw = max($mQ9Jw, 1); goto ciU9L; VoiY1: for ($QhDyd = $GPUL4; $QhDyd < $GPUL4 + $UcEVj; $QhDyd++) { if (!isset($y2SDh[$QhDyd])) { break; } $CRNa9[] = $y2SDh[$QhDyd]; } goto Q3uEl; Q3uEl: return $CRNa9; goto wbfHQ; JNpf6: if (!isset($y2SDh[$GPUL4])) { return array(); } goto SDWmC; SDWmC: $CRNa9 = array(); goto VoiY1; ciU9L: $GPUL4 = max($mQ9Jw - 1, 0) * $UcEVj; goto JNpf6; wbfHQ: } public function paginate($mQ9Jw, $UcEVj) { $y2SDh = $this->all(); return $this->idsPaginate($y2SDh, $mQ9Jw, $UcEVj); } public function paginateRandom($mQ9Jw, $UcEVj, $E9OkN = 'all', $RheW3 = 60) { $y2SDh = Cache::remember($this->name() . '_Random_' . $E9OkN, $RheW3, function () { $y2SDh = $this->all(); shuffle($y2SDh); return $y2SDh; }); return $this->idsPaginate($y2SDh, $mQ9Jw, $UcEVj); } public function forgetRandom($E9OkN = 'all') { Cache::forget($this->name() . '_Random_' . $E9OkN); } }