当前位置: 首页>>代码示例>>PHP>>正文


PHP Facades\Cache类代码示例

本文整理汇总了PHP中Illuminate\Support\Facades\Cache的典型用法代码示例。如果您正苦于以下问题:PHP Cache类的具体用法?PHP Cache怎么用?PHP Cache使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Cache类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: handle

 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     if ($this->option('tracks') === 'all') {
         // Get all cacheable track files
         $trackFiles = TrackFile::where('is_cacheable', true)->with('track.album')->get();
     } else {
         // Get all expired track files
         $trackFiles = TrackFile::where('is_cacheable', true)->where('expires_at', '<=', Carbon::now())->with('track.album')->get();
     }
     // Delete above track files
     if (count($trackFiles) === 0) {
         $this->info('No tracks found. Exiting.');
     } else {
         if ($this->option('force') || $this->confirm(count($trackFiles) . ' cacheable track files found. Proceed to delete their files if they exist? [y|N]', false)) {
             $count = 0;
             foreach ($trackFiles as $trackFile) {
                 // Set expiration to null (so can be re-cached upon request)
                 $trackFile->expires_at = null;
                 $trackFile->update();
                 // Delete file if exists
                 if (File::exists($trackFile->getFile())) {
                     $count++;
                     File::delete($trackFile->getFile());
                     $this->info('Deleted ' . $trackFile->getFile());
                 }
                 // Remove the cached file size for the album
                 Cache::forget($trackFile->track->album->getCacheKey('filesize-' . $trackFile->format));
             }
             $this->info($count . ' files deleted. Deletion complete. Exiting.');
         } else {
             $this->info('Deletion cancelled. Exiting.');
         }
     }
 }
开发者ID:nsystem1,项目名称:Pony.fm,代码行数:39,代码来源:ClearTrackCache.php

示例2: show

 public function show()
 {
     $options = Config::get('onepager.options');
     $progressBar = Cache::get('progressBar', function () {
         $c = curl_init('https://www.startnext.com/sanktionsfrei/widget/?w=200&amp;h=300&amp;l=de');
         curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
         $html = curl_exec($c);
         if (curl_error($c)) {
             die(curl_error($c));
         }
         $status = curl_getinfo($c, CURLINFO_HTTP_CODE);
         curl_close($c);
         $percent = 0;
         if ($status == 200) {
             $crawler = new Crawler();
             $crawler->addHTMLContent($html, 'UTF-8');
             // get the percentage for the progressbar
             $styleString = $crawler->filter('.bar.bar-1')->attr('style');
             $stringArray = explode(':', $styleString);
             $percent = substr($stringArray[1], 0, -2);
             // get the text for the progressbar
             $textArray = $crawler->filter('.status-text span')->extract(['_text']);
         }
         return ['percent' => $percent, 'progressText' => $textArray[0]];
     }, 5);
     return view('home', ['options' => $options, 'percent' => $progressBar['percent'], 'progressText' => $progressBar['progressText']]);
 }
开发者ID:johannesponader,项目名称:Onepager,代码行数:27,代码来源:WelcomeController.php

示例3: getClear

 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function getClear()
 {
     // Cache::forget('settings');
     // Cache::forget('popular_categories');
     Cache::flush();
     return redirect()->back()->withSuccess('Cache Cleared!');
 }
开发者ID:ambarsetyawan,项目名称:brewski,代码行数:12,代码来源:CacheController.php

示例4: putAll

 /**
  * Handle permissions change
  *
  * @param Request $request
  * @return \Illuminate\Http\RedirectResponse
  */
 public function putAll(Request $request)
 {
     $permissions = Permission::all();
     $input = array_keys($request->input('permissions'));
     try {
         DB::beginTransaction();
         $permissions->each(function ($permission) use($input) {
             if (in_array($permission->id, $input)) {
                 $permission->allow = true;
             } else {
                 $permission->allow = false;
             }
             $permission->save();
         });
         DB::commit();
         flash()->success(trans('permissions.save_success'));
     } catch (\Exception $e) {
         var_dump($e->getMessage());
         die;
         flash()->error(trans('permissions.save_error'));
     }
     try {
         Cache::tags(['permissions'])->flush();
     } catch (\Exception $e) {
         Cache::flush();
     }
     return redirect()->back();
 }
开发者ID:Denniskevin,项目名称:Laravel5Starter,代码行数:34,代码来源:AdminPermissionsController.php

示例5: index

 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $fabricantes = Cache::remember('fabricantes', 15 / 60, function () {
         return Fabricante::simplePaginate(15);
     });
     return response()->json(['siguiente' => $fabricantes->nextPageUrl(), 'anterior' => $fabricantes->previousPageUrl(), 'datos' => $fabricantes->items()], 200);
 }
开发者ID:osvaldino,项目名称:RESTful-API,代码行数:12,代码来源:FabricanteController.php

示例6: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (app()->environment() == 'local') {
         Cache::tags('views')->flush();
     }
     return $next($request);
 }
开发者ID:steveazz,项目名称:rudolly,代码行数:14,代码来源:FlushView.php

示例7: getLatestBans

 /**
  * Gets the latest bans
  * @param  string  $cacheKey Caching key to use
  * @param  integer $ttl      Cache for X minutes
  * @return array
  */
 public function getLatestBans($cacheKey = 'bans.latest', $ttl = 1)
 {
     $bans = Cache::remember($cacheKey, $ttl, function () {
         return Ban::with('player', 'record')->latest(30)->get()->toArray();
     });
     return $bans;
 }
开发者ID:R3alflash,项目名称:BFAdminCP,代码行数:13,代码来源:BanRepository.php

示例8: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request $request
  * @param  \Closure $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (Cache::get('role.' . Auth::id()) == 'admin') {
         return $next($request);
     }
     abort(404);
 }
开发者ID:uusa35,项目名称:turnkw,代码行数:14,代码来源:AdminZone.php

示例9: getTimestampMigrationName

 /**
  * @return string
  */
 protected function getTimestampMigrationName()
 {
     if (!Cache::has(static::CACHENAME)) {
         Cache::forever(static::CACHENAME, date('Y_m_d_His') . '_' . $this->getMigrationName());
     }
     return Cache::get(static::CACHENAME);
 }
开发者ID:jayaregalinada,项目名称:common,代码行数:10,代码来源:OptionServiceProvider.php

示例10: isAdmin

 public function isAdmin()
 {
     if (Cache::has('role.' . Auth::id()) && Cache::get('role.' . Auth::id()) === 'admin') {
         return true;
     }
     return false;
 }
开发者ID:uusa35,项目名称:turnkw,代码行数:7,代码来源:UserTrait.php

示例11: schedule

 /**
  * Define the application's command schedule.
  *
  * @param  \Illuminate\Console\Scheduling\Schedule  $schedule
  * @return void
  */
 protected function schedule(Schedule $schedule)
 {
     $schedule->call(function () {
         Cache::put('last-cron', new Carbon(), 5);
     })->everyMinute();
     $schedule->command('inspire')->hourly();
 }
开发者ID:atrauzzi,项目名称:laravel-drydock,代码行数:13,代码来源:Kernel.php

示例12: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle(Request $request, Closure $next)
 {
     $key = $this->buildCacheKey($request);
     return Cache::remember($key, static::CACHE_MINUTES, function () use($request, $next) {
         return $next($request);
     });
 }
开发者ID:hussainweb,项目名称:drupal-stats,代码行数:14,代码来源:CacheMiddleware.php

示例13: update

 public function update($id)
 {
     try {
         $groups = Cache::get('admin.adkats.special.groups');
         $player = Special::findOrFail($id);
         foreach ($groups as $group) {
             if ($group['group_key'] == Input::get('group')) {
                 $newGroup = $group['group_name'];
                 break;
             }
         }
         $player->player_group = Input::get('group');
         $player->save();
         if (is_null($player->player)) {
             $soldierName = $player->player_identifier;
         } else {
             $soldierName = $player->player->SoldierName;
         }
         $message = sprintf('%s group has been changed to %s.', $soldierName, $newGroup);
         return MainHelper::response(null, $message);
     } catch (ModelNotFoundException $e) {
         $message = sprintf('No player found with special id of %u', $id);
         return MainHelper::response(null, $message, 'error', 404);
     } catch (Exception $e) {
         return MainHelper::response($e, $e->getMessage(), 'error', 500);
     }
 }
开发者ID:BP4U,项目名称:BFAdminCP,代码行数:27,代码来源:SpecialPlayersController.php

示例14: _fetchDataset

 private function _fetchDataset($filter)
 {
     return Cache::get($this->key, function () use($filter) {
         Cache::add($this->key, $data = $this->_getDataPartialRecursive($filter), 60);
         return $data;
     });
 }
开发者ID:skizu,项目名称:freshdeskreporting,代码行数:7,代码来源:DataController.php

示例15: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (!Cache::has('session.key')) {
         return redirect('/')->with('error', 'You must log in in order to view that page.');
     }
     return $next($request);
 }
开发者ID:pasadinhas,项目名称:sirs-project,代码行数:14,代码来源:BusDriver.php


注:本文中的Illuminate\Support\Facades\Cache类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。