本文整理匯總了PHP中Illuminate\Support\Facades\Cache::tags方法的典型用法代碼示例。如果您正苦於以下問題:PHP Cache::tags方法的具體用法?PHP Cache::tags怎麽用?PHP Cache::tags使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Illuminate\Support\Facades\Cache
的用法示例。
在下文中一共展示了Cache::tags方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: handle
/**
* @inheritdoc
*/
public function handle($arguments)
{
if (!Cache::has('site-' . $arguments)) {
$this->replyWithMessage("Não foi encontrado nenhum site com esse argumento.");
return;
}
$site = Cache::get('site-' . $arguments);
// Validate if the URL isn't on the database yet
if (Site::where('url', '=', $site)->first() != null) {
$this->replyWithMessage("O site {$site} já se encontra na base de dados.");
return;
}
$site_obj = new Site();
$site_obj->url = $site;
$site_obj->save();
$this->replyWithMessage($site . " foi adicionado à base de dados.", true);
// Notify the sitesbloqueados.pt about the new site
$url = 'https://sitesbloqueados.pt/wp-json/ahoy/refresh';
$cmd = "curl -X GET -H 'Content-Type: application/json'";
$cmd .= " " . "'" . $url . "'";
$cmd .= " > /dev/null 2>&1 &";
exec($cmd, $output);
// Flush the PAC cache
Cache::tags(['generate_pac'])->flush();
// Remove the cache
Cache::forget('site-' . $arguments);
Cache::forget('site-list');
}
示例2: restore
public function restore()
{
//soft delete undo's
$result = parent::restore();
Cache::tags(Config::get('entrust.permission_role_table'))->flush();
return $result;
}
示例3: onTagsFlush
public function onTagsFlush()
{
$tags = $this->controller->getDefinitionOption('cache.tags', array());
foreach ($tags as $tag) {
Cache::tags($tag)->flush();
}
}
示例4: 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);
}
示例5: boot
/**
* Register any other events for your application.
*
* @param \Illuminate\Contracts\Events\Dispatcher $events
* @return void
*/
public function boot(DispatcherContract $events)
{
parent::boot($events);
Feedback::created(function ($item) {
Cache::tags('feedbacks')->flush();
$this->dispatch(new SentenceProcessing($item));
});
Feedback::updated(function ($item) {
Cache::tags('feedbacks')->flush();
});
Feedback::deleted(function ($item) {
Cache::tags('feedbacks')->flush();
});
Comment::saved(function ($item) {
Cache::tags('comments')->flush();
});
Comment::saved(function ($item) {
Cache::tags('comments')->flush();
});
Sentence::saved(function ($item) {
if ($item->feedback) {
$item->feedback->calculateProbabilities();
}
});
}
示例6: 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();
}
示例7: restore
public function restore()
{
//soft delete undo's
parent::restore();
Cache::tags('permission_section_users')->flush();
Cache::tags('role_user')->flush();
}
示例8: getCacheInstance
/**
* Gets the cache engine instance. This method is used when the cache is referenced
* with tags. In some cases like if the active cache driver is file, then the tags
* method does not work and throws exception.
*
* @param array $cacheTags
* @return mixed
*/
protected static function getCacheInstance(array $cacheTags)
{
try {
return Cache::tags($cacheTags);
} catch (\ErrorException $e) {
return Cache::getFacadeRoot();
}
}
示例9: remember
public static function remember($key, $callback)
{
if (!Cache::has($key)) {
$value = $callback();
Cache::tags(self::TAG)->put($key, $value, 60);
}
return Cache::tags(self::TAG)->get($key);
}
示例10: getSystemConfig
public function getSystemConfig($field)
{
if (empty($value = Cache::tags(self::REDIS_SYSTEM_CONFIG)->get(self::REDIS_SYSTEM_CONFIG . $field))) {
$value = self::select('system_value')->where('system_key', $field)->pluck('system_value');
Cache::tags(self::REDIS_SYSTEM_CONFIG)->put(self::REDIS_SYSTEM_CONFIG . $field, $value, config('site')['redis_cache_time']);
}
return $value;
}
示例11: restore
public function restore()
{
//soft delete undo's
parent::restore();
if (Cache::getStore() instanceof TaggableStore) {
Cache::tags(Config::get('entrust.role_user_table'))->flush();
}
}
示例12: findMany
/**
* Find a model by its primary key.
*
* @param array $ids
* @param array $columns
*
* @return \Illuminate\Database\Eloquent\Collection
*/
public function findMany($ids, $columns = ['*'])
{
if (empty($ids)) {
return $this->model->newCollection();
}
return $this->model->newCollection(Cache::tags($this->model->getTable())->rememberMany($ids, $this->model->cacheExpiry, function ($ids) use($columns) {
return parent::findMany($ids, $columns)->all();
}));
}
示例13: restore
public function restore()
{
//soft delete undo's
if (!parent::restore()) {
return false;
}
Cache::tags(Config::get('entrust.permission_role_table'))->flush();
return true;
}
示例14: setCache
protected function setCache($shareCount)
{
$minutes = config('yaro.soc-share.cache_minutes');
if (!$minutes) {
return null;
}
$key = $this->provider . '.' . md5(serialize($this->options));
return Cache::tags('soc-share')->put($key, $shareCount, $minutes);
}
示例15: index
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
$feedbacks = Cache::tags(['feedbacks', 'index', 'comments'])->get('feedbacks.index');
if (!$feedbacks) {
$feedbacks = Feedback::with('status', 'visibility', 'comments')->get()->sortBy('created_at');
Cache::tags(['feedbacks', 'index', 'comments'])->put('feedbacks.index', $feedbacks, 1);
}
return view('backend.feedbacks.index', ['feedbacks' => $feedbacks]);
}