<?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($dhq1u) { $this->clearCache(); } public function remove($dhq1u) { $this->clearCache(); } public function total() { return count($this->all()); } private function idsPaginate(&$dhq1u, $evgNV, $wo2xO) { goto xtzbh; xtzbh: $evgNV = max($evgNV, 1); goto LZJuO; NXcXv: for ($qzlby = $V8URf; $qzlby < $V8URf + $wo2xO; $qzlby++) { if (!isset($dhq1u[$qzlby])) { break; } $QCW2U[] = $dhq1u[$qzlby]; } goto oMM5G; LZJuO: $V8URf = max($evgNV - 1, 0) * $wo2xO; goto JRsvD; keqvl: $QCW2U = array(); goto NXcXv; oMM5G: return $QCW2U; goto i3QTA; JRsvD: if (!isset($dhq1u[$V8URf])) { return array(); } goto keqvl; i3QTA: } public function paginate($evgNV, $wo2xO) { $dhq1u = $this->all(); return $this->idsPaginate($dhq1u, $evgNV, $wo2xO); } public function paginateRandom($evgNV, $wo2xO, $uUp5p = 'all', $FOUT1 = 60) { $dhq1u = Cache::remember($this->name() . '_Random_' . $uUp5p, $FOUT1, function () { $dhq1u = $this->all(); shuffle($dhq1u); return $dhq1u; }); return $this->idsPaginate($dhq1u, $evgNV, $wo2xO); } public function forgetRandom($uUp5p = 'all') { Cache::forget($this->name() . '_Random_' . $uUp5p); } }