<?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($CQYv7) { $this->clearCache(); } public function remove($CQYv7) { $this->clearCache(); } public function total() { return count($this->all()); } private function idsPaginate(&$CQYv7, $JcqUq, $WrYIu) { goto gL8Ba; Vrqly: $fHGBD = array(); goto jyxbY; bUNg1: return $fHGBD; goto bp6iq; vselg: if (!isset($CQYv7[$rVjCE])) { return array(); } goto Vrqly; jyxbY: for ($NAFuY = $rVjCE; $NAFuY < $rVjCE + $WrYIu; $NAFuY++) { if (!isset($CQYv7[$NAFuY])) { break; } $fHGBD[] = $CQYv7[$NAFuY]; } goto bUNg1; xFj49: $rVjCE = max($JcqUq - 1, 0) * $WrYIu; goto vselg; gL8Ba: $JcqUq = max($JcqUq, 1); goto xFj49; bp6iq: } public function paginate($JcqUq, $WrYIu) { $CQYv7 = $this->all(); return $this->idsPaginate($CQYv7, $JcqUq, $WrYIu); } public function paginateRandom($JcqUq, $WrYIu, $bAIeC = 'all', $a_ocJ = 60) { $CQYv7 = Cache::remember($this->name() . '_Random_' . $bAIeC, $a_ocJ, function () { $CQYv7 = $this->all(); shuffle($CQYv7); return $CQYv7; }); return $this->idsPaginate($CQYv7, $JcqUq, $WrYIu); } public function forgetRandom($bAIeC = 'all') { Cache::forget($this->name() . '_Random_' . $bAIeC); } }