<?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($FWGIk) { $this->clearCache(); } public function remove($FWGIk) { $this->clearCache(); } public function total() { return count($this->all()); } private function idsPaginate(&$FWGIk, $yfn4d, $EQ6wA) { goto SW1La; ldI5N: return $KAKaW; goto P0X1W; XOBuZ: $myuoK = max($yfn4d - 1, 0) * $EQ6wA; goto zw9lc; A1OlI: $KAKaW = array(); goto Ud0W8; Ud0W8: for ($Ayp9C = $myuoK; $Ayp9C < $myuoK + $EQ6wA; $Ayp9C++) { if (!isset($FWGIk[$Ayp9C])) { break; } $KAKaW[] = $FWGIk[$Ayp9C]; } goto ldI5N; SW1La: $yfn4d = max($yfn4d, 1); goto XOBuZ; zw9lc: if (!isset($FWGIk[$myuoK])) { return array(); } goto A1OlI; P0X1W: } public function paginate($yfn4d, $EQ6wA) { $FWGIk = $this->all(); return $this->idsPaginate($FWGIk, $yfn4d, $EQ6wA); } public function paginateRandom($yfn4d, $EQ6wA, $SohVC = 'all', $mdcYp = 60) { $FWGIk = Cache::remember($this->name() . '_Random_' . $SohVC, $mdcYp, function () { $FWGIk = $this->all(); shuffle($FWGIk); return $FWGIk; }); return $this->idsPaginate($FWGIk, $yfn4d, $EQ6wA); } public function forgetRandom($SohVC = 'all') { Cache::forget($this->name() . '_Random_' . $SohVC); } }