本文整理汇总了PHP中Illuminate\Support\Facades\Cache类的典型用法代码示例。如果您正苦于以下问题:PHP Cache类的具体用法?PHP Cache怎么用?PHP Cache使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Cache类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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&h=300&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
示例16: compose
/**
* Bind data to the view.
*
* @param View $view
* @return void
*/
public function compose(View $view)
{
if (!Cache::get('popular_categories')) {
Cache::put('popular_categories', $this->categories->getPopular(), 60);
}
$view->with('popular_categories', Cache::get('popular_categories'));
}
开发者ID:ambarsetyawan,项目名称:brewski,代码行数:13,代码来源:PopularCategoriesComposer.php
示例17: boot
public static function boot()
{
parent::boot();
Webhook::creating(function ($results) {
Cache::forget('webhooks');
});
}
开发者ID:alfred-nutile-inc,项目名称:webhooks,代码行数:7,代码来源:Webhook.php
示例18: put
public function put(Route $route, Request $request, Response $response)
{
$key = $this->makeCacheKey($request->url());
if (!Cache::has($key)) {
Cache::put($key, $response->getContent(), 10);
}
}
开发者ID:RichJones22,项目名称:TimeTrax,代码行数:7,代码来源:CacheFilters.php
示例19: array
/**
* Setup for Google API authorization to retrieve directory data
*/
function __construct()
{
// set config options
$clientId = Config::get('google.client_id');
$serviceAccountName = Config::get('google.service_account_name');
$delegatedAdmin = Config::get('google.admin_email');
$keyFile = base_path() . Config::get('google.key_file_location');
$appName = Config::get('google.app_name');
// array of scopes
$scopes = array('https://www.googleapis.com/auth/admin.directory.user', 'https://www.googleapis.com/auth/admin.directory.user.readonly');
// Create AssertionCredentails object for use with Google_Client
$creds = new \Google_Auth_AssertionCredentials($serviceAccountName, $scopes, file_get_contents($keyFile));
// set admin identity for API requests
$creds->sub = $delegatedAdmin;
// Create Google_Client to allow making API calls
$this->client = new \Google_Client();
$this->client->setApplicationName($appName);
$this->client->setClientId($clientId);
$this->client->setAssertionCredentials($creds);
if ($this->client->getAuth()->isAccessTokenExpired()) {
$this->client->getAuth()->refreshTokenWithAssertion($creds);
}
Cache::forever('service_token', $this->client->getAccessToken());
// Set instance of Directory object for making Directory API related calls
$this->service = new \Google_Service_Directory($this->client);
}
开发者ID:staciewilhelm,项目名称:denver-member-tracking,代码行数:29,代码来源:GoogleDirectory.php
示例20: boot
/**
* Bootstrap the application services.
*/
public function boot()
{
parent::boot();
$this->publishMigrations();
$app = $this->app;
if ($app->bound('form')) {
$app->form->macro('selectCountry', function ($name, $selected = null, $options = []) use($app) {
$countries = Cache::rememberForever('brianfaust.countries.select.name.cca2', function () {
$records = Country::get(['name', 'cca2']);
$countries = new Collection();
$records->map(function ($item) use(&$countries) {
$countries[$item['cca2']] = $item['name']['official'];
});
return $countries->sort();
});
return $app->form->select($name, $countries, $selected, $options);
});
$app->form->macro('selectCountryWithId', function ($name, $selected = null, $options = []) use($app) {
$countries = Cache::rememberForever('brianfaust.countries.select.id.cca2', function () {
$records = Country::get(['name', 'id']);
$countries = new Collection();
$records->map(function ($item) use(&$countries) {
$countries[$item['id']] = $item['name']['official'];
});
return $countries->sort();
});
return $app->form->select($name, $countries, $selected, $options);
});
}
}
开发者ID:DraperStudio,项目名称:Laravel-Countries,代码行数:33,代码来源:CountriesServiceProvider.php
注:本文中的Illuminate\Support\Facades\Cache类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论