<?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($k30iT) { $this->clearCache(); } public function remove($k30iT) { $this->clearCache(); } public function total() { return count($this->all()); } private function idsPaginate(&$k30iT, $WLCMC, $Aqj3Z) { goto rN27s; wtqi5: $H_aKg = array(); goto zjk3G; KY7CR: if (!isset($k30iT[$Oau4H])) { return array(); } goto wtqi5; zjk3G: for ($Iy3ah = $Oau4H; $Iy3ah < $Oau4H + $Aqj3Z; $Iy3ah++) { if (!isset($k30iT[$Iy3ah])) { break; } $H_aKg[] = $k30iT[$Iy3ah]; } goto N7Wzx; N7Wzx: return $H_aKg; goto NswzH; rN27s: $WLCMC = max($WLCMC, 1); goto uv86V; uv86V: $Oau4H = max($WLCMC - 1, 0) * $Aqj3Z; goto KY7CR; NswzH: } public function paginate($WLCMC, $Aqj3Z) { $k30iT = $this->all(); return $this->idsPaginate($k30iT, $WLCMC, $Aqj3Z); } public function paginateRandom($WLCMC, $Aqj3Z, $SSvLs = 'all', $ZfC1h = 60) { $k30iT = Cache::remember($this->name() . '_Random_' . $SSvLs, $ZfC1h, function () { $k30iT = $this->all(); shuffle($k30iT); return $k30iT; }); return $this->idsPaginate($k30iT, $WLCMC, $Aqj3Z); } public function forgetRandom($SSvLs = 'all') { Cache::forget($this->name() . '_Random_' . $SSvLs); } }