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


PHP Cache::tags方法代码示例

本文整理汇总了PHP中Cache::tags方法的典型用法代码示例。如果您正苦于以下问题:PHP Cache::tags方法的具体用法?PHP Cache::tags怎么用?PHP Cache::tags使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Cache的用法示例。


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

示例1: showIndex

 public function showIndex()
 {
     $page = $this->node;
     $tree = Collector::get('root');
     $subTree = Tree::getSubTree($tree, $page);
     $blocks = null;
     if ($subTree) {
         $blocks = $subTree->children;
     }
     foreach ($blocks as $index => $block) {
         $blocks[$block->slug] = $block;
         unset($blocks[$index]);
     }
     if (isset($blocks['reporting'])) {
         $blocks['reporting']->children = $blocks['reporting']->children->reverse();
         $reporting = $blocks['reporting'];
     }
     $flatArticles = Cache::tags('j_tree')->rememberForever('about_flat_articles_' . App::getLocale(), function () use($page) {
         return $page->immediateDescendants()->active()->get();
     });
     $articles = array();
     foreach ($flatArticles as $article) {
         $articles[$article->slug] = $article;
     }
     $pressSections = null;
     if (isset($articles['press']) && $articles['press']->count()) {
         $pressSubTree = Tree::getSubTree($tree, $articles['press']);
         if ($pressSubTree) {
             $pressSections = $pressSubTree->children;
         }
     }
     return View::make('about.index', compact('page', 'reporting', 'articles', 'pressSections'));
 }
开发者ID:OlesKashchenko,项目名称:SkillsProject1,代码行数:33,代码来源:AboutController.php

示例2: render

 public static function render($page, $position = '')
 {
     $page = !$page ? 'null' : $page;
     if (Cache::tags('widgets')->has($page . '-' . $position)) {
         $merged = Cache::tags('widgets')->get($page . '-' . $position);
     } else {
         if ($page == 'null') {
             $merged = Widget::select('id', 'title', 'content', 'path')->active()->global()->wherePosition($position)->orderBy('ordr', 'ASC')->get();
         } else {
             $global = Widget::select('id', 'title', 'content', 'path')->active()->global()->wherePosition($position)->orderBy('ordr', 'ASC')->get();
             $specific = $page->widgets()->select('id', 'title', 'content', 'path')->local()->wherePosition($position)->orderBy('ordr', 'ASC')->get();
             $merged = $global->merge($specific);
         }
         $merged->sortBy('ordr');
         Cache::tags('widgets')->forever($page . '-' . $position, $merged);
     }
     foreach ($merged as $widget) {
         if ($widget->path) {
             if (\View::exists($widget->path)) {
                 echo view($widget->path);
             }
         } else {
             echo str_replace('{{url}}', Request::url(), $widget->content);
         }
     }
 }
开发者ID:matheusgomes17,项目名称:berrier,代码行数:26,代码来源:Widget.php

示例3: UserPermissions

 public function UserPermissions()
 {
     if (Auth::check()) {
         $user_id = Auth::id();
         $cache_key = "user-" . $user_id . "-permissions";
         if (Cache::tags('user-permissions')->has($cache_key)) {
             $permission_array = Cache::tags('user-permissions')->get($cache_key);
         } else {
             if (Auth::user()->is_admin) {
                 $raw_permission_array = [];
                 $permission_array = [];
                 $permission_objects = Permission::all();
                 $user_permissions = DB::table('permission_user')->where('user_id', '=', $user_id)->get();
                 foreach ($user_permissions as $user_permission) {
                     $permission_id = $user_permission->permission_id;
                     $raw_permission_array[$permission_id] = 1;
                 }
                 foreach ($permission_objects as $permission) {
                     $route_name = $permission->route;
                     $permission_id = $permission->id;
                     if (isset($raw_permission_array[$permission_id])) {
                         $permission_array[$route_name] = $raw_permission_array[$permission_id];
                     } else {
                         $permission_array[$route_name] = 0;
                     }
                 }
             } else {
                 $permission_array = false;
             }
             Cache::tags('user-permissions')->put($cache_key, $permission_array, 60);
         }
     }
     return $permission_array;
 }
开发者ID:helkarakse,项目名称:modpackindex,代码行数:34,代码来源:BaseController.php

示例4: makeSlugUnique

 private function makeSlugUnique($slug)
 {
     // if using the cache, check if we have an entry already instead
     // of querying the database
     if ($this->use_cache) {
         $increment = Cache::tags('sluggable')->get($slug);
         if ($increment === null) {
             Cache::tags('sluggable')->put($slug, 0, $use_cache);
         } else {
             Cache::tags('sluggable')->put($slug, ++$increment, $use_cache);
             $slug .= $this->separator . $increment;
         }
         return $slug;
     }
     // no cache, so we need to check directly
     // find all models where the slug is like the current one
     $list = $this->getExistingSlugs($slug);
     // if ...
     //  a) the list is empty
     //  b) our slug isn't in the list
     //  c) our slug is in the list and it's for our model
     // ... we are okay
     if (count($list) === 0 || !in_array($slug, $list) || $this->id && array_key_exists($this->id, $list) && $list[$this->id] === $slug) {
         return $slug;
     }
     // map our list to keep only the increments
     $len = strlen($slug . $this->separator);
     array_walk($list, function (&$value, $key) use($len) {
         $value = intval(substr($value, $len));
     });
     // find the highest increment
     rsort($list);
     $increment = reset($list) + 1;
     return $slug . $this->separator . $increment;
 }
开发者ID:sh1nu11bi,项目名称:CloMa,代码行数:35,代码来源:SlugHelper.php

示例5: postEdit

 public function postEdit($id)
 {
     if (!$this->checkRoute()) {
         return Redirect::route('index');
     }
     $title = 'Edit A Modpack Code - ' . $this->site_name;
     $input = Input::only('code', 'launcher', 'modpack');
     $modpackcode = ModpackCode::find($id);
     $messages = ['unique' => 'A code for this launcher/modpack combination already exists in the database!'];
     $validator = Validator::make($input, ['code' => 'required|unique:modpack_codes,code,' . $modpackcode->id, 'launcher' => 'required', 'modpack' => 'required'], $messages);
     if ($validator->fails()) {
         // TODO this line originally redirects to modpack-code/edit, there's no route for this, is this an error?
         return Redirect::action('ModpackCodeController@getEdit', [$id])->withErrors($validator)->withInput();
     }
     $modpackcode->code = $input['code'];
     $modpackcode->modpack_id = $input['modpack'];
     $modpackcode->launcher_id = $input['launcher'];
     $modpackcode->last_ip = Request::getClientIp();
     $success = $modpackcode->save();
     if ($success) {
         Cache::tags('modpacks')->flush();
         Queue::push('BuildCache');
         return View::make('modpackcodes.edit', ['title' => $title, 'success' => true, 'modpackcode' => $modpackcode]);
     }
     return Redirect::action('ModpackCodeController@getEdit', [$id])->withErrors(['message' => 'Unable to add modpack code.'])->withInput();
 }
开发者ID:helkarakse,项目名称:modpackindex,代码行数:26,代码来源:ModpackCodeController.php

示例6: update

 /**
  * Update the specified resource in storage.
  *
  * @param int $id
  *
  * @return Response
  */
 public function update(CategoryRequest $request, $id)
 {
     $category = Category::findOrFail($id);
     $category->update($request->all());
     \Cache::tags('categories')->flush();
     return redirect('admin/categories/index');
 }
开发者ID:kpaxer,项目名称:laravel-blog,代码行数:14,代码来源:CategoriesController.php

示例7: showMain

 public function showMain()
 {
     $page = $this->node;
     $tree = Collector::get('root');
     $subTree = Tree::getSubTree($tree, $page);
     $blocks = null;
     if ($subTree) {
         $blocks = $subTree->children;
     }
     foreach ($blocks as $index => $block) {
         $blocks[$block->slug] = $block;
         unset($blocks[$index]);
     }
     $allRates = Cache::tags('rates')->rememberForever('rates_' . App::getLocale(), function () {
         return Rates::orderPriority()->get();
     });
     $rates = array();
     foreach ($allRates as $i => $rate) {
         if ($rate['type'] == 1) {
             $rates['departments'][] = $rate;
         } else {
             $rates['cards'][$rate['name_card']][] = $rate;
         }
     }
     $calculatorCredit = new CashCalculator();
     // fixme:
     //$calculatorCredit->setMonthlyIncome(Settings::get('monthly_income_default', 0));
     $calculatorCredit->setCreditAmount(Settings::get('credit_amount_default', 100000));
     $calculatorCredit->setTerm(Settings::get('term_default', 3));
     $calculationsCredit = $calculatorCredit->calculate();
     return View::make('index', compact('page', 'blocks', 'rates', 'calculationsCredit'));
 }
开发者ID:OlesKashchenko,项目名称:SkillsProject1,代码行数:32,代码来源:HomeController.php

示例8: boot

 public static function boot()
 {
     parent::boot();
     Widget::saved(function ($widget) {
         \Cache::tags('widgets')->flush();
     });
 }
开发者ID:matheusgomes17,项目名称:berrier,代码行数:7,代码来源:Widget.php

示例9: postEdit

 public function postEdit($id)
 {
     if (!$this->checkRoute()) {
         return Redirect::route('index');
     }
     $title = 'Edit A Modpack Code - ' . $this->site_name;
     $input = Input::only('name', 'deck', 'description', 'slug');
     $modpacktag = ModpackTag::find($id);
     $messages = ['unique' => 'This modpack tag already exists in the database!'];
     $validator = Validator::make($input, ['name' => 'required|unique:modpack_tags,name,' . $modpacktag->id, 'deck' => 'required'], $messages);
     if ($validator->fails()) {
         return Redirect::action('ModpackTagController@getEdit', [$id])->withErrors($validator)->withInput();
     }
     $modpacktag->name = $input['name'];
     $modpacktag->deck = $input['deck'];
     $modpacktag->description = $input['description'];
     $modpacktag->last_ip = Request::getClientIp();
     if ($input['slug'] == '' || $input['slug'] == $modpacktag->slug) {
         $slug = Str::slug($input['name']);
     } else {
         $slug = $input['slug'];
     }
     $modpacktag->slug = $slug;
     $success = $modpacktag->save();
     if ($success) {
         Cache::tags('modpacks')->flush();
         Queue::push('BuildCache');
         return View::make('tags.modpacks.edit', ['title' => $title, 'success' => true, 'modpacktag' => $modpacktag]);
     }
     return Redirect::action('ModpackTagController@getEdit', [$id])->withErrors(['message' => 'Unable to edit modpack code.'])->withInput();
 }
开发者ID:helkarakse,项目名称:modpackindex,代码行数:31,代码来源:ModpackTagController.php

示例10: flush

 public function flush(BasicAPIController $api)
 {
     $config = $this->config($api);
     if ($config['flush']) {
         \Cache::tags($config['flush_tags'])->flush();
     }
 }
开发者ID:xjtuwangke,项目名称:laravel-api,代码行数:7,代码来源:BasicAPICacher.php

示例11: showCatalogSecond

 public function showCatalogSecond()
 {
     $page = $this->node;
     $products = Cache::tags('j_tree')->rememberForever('small_business_products_catalog_' . $page->id . '_' . App::getLocale(), function () use($page) {
         return $page->immediateDescendants()->where('is_active', 'like', '%' . App::getLocale() . '%')->get();
     });
     return View::make('small-business.catalog_second', compact('page', 'products'));
 }
开发者ID:OlesKashchenko,项目名称:SkillsProject1,代码行数:8,代码来源:SmallBusinessController.php

示例12: showCatalogFirst

 public function showCatalogFirst()
 {
     $page = $this->node;
     $products = Cache::tags('j_tree')->rememberForever('financial_products_' . App::getLocale(), function () use($page) {
         return $page->immediateDescendants()->active()->catalogItems()->get();
     });
     return View::make('financial.catalog_first', compact('page', 'products'));
 }
开发者ID:OlesKashchenko,项目名称:SkillsProject1,代码行数:8,代码来源:FinancialController.php

示例13: getCitiesByRegion

 public function getCitiesByRegion()
 {
     $idRegion = trim(Input::get('id_region')) ?: 0;
     $cities = Cache::tags('cities')->rememberForever('cities_region_' . $idRegion . '_' . App::getLocale(), function () use($idRegion) {
         return City::active()->byRegion($idRegion)->get();
     });
     $html = View::make('partials.popups.partials.select_city', compact('cities'))->render();
     return Response::json(array('status' => true, 'html' => $html));
 }
开发者ID:OlesKashchenko,项目名称:SkillsProject1,代码行数:9,代码来源:AsyncController.php

示例14: last_modified

function last_modified($path)
{
    $mtime = Cache::tags('mtime')->get($path, false);
    if (!$mtime || Config::get('app.debug')) {
        $mtime = filemtime(public_path() . $path);
        Cache::tags('mtime')->put($path, $mtime, 5);
    }
    return $path . '?' . $mtime;
}
开发者ID:nanaya,项目名称:osu-web,代码行数:9,代码来源:osu.php

示例15: loadPartsbyPageId

 /**
  * @param integer $pageId
  * @return array|null
  */
 private static final function loadPartsbyPageId($pageId)
 {
     if (!array_key_exists($pageId, static::$cached)) {
         self::$cached[$pageId] = Cache::tags(PagePartModel::table())->remember("pageParts::{$pageId}", Carbon::now()->addHour(1), function () use($pageId) {
             return PagePartModel::select('name', 'content', 'content_html')->where('page_id', $pageId)->get();
         });
     }
     return self::$cached[$pageId];
 }
开发者ID:BlueCatTAT,项目名称:kodicms-laravel,代码行数:13,代码来源:PagePart.php


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