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


PHP Cache::remember方法代码示例

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


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

示例1: testRemember

 public function testRemember()
 {
     $this->assertEquals("bar2", $this->cache->remember("foo2", function () {
         return "bar2";
     }));
     $this->assertEquals("bar2", $this->cache->remember("foo2", function () {
         return "this will never be set";
     }));
 }
开发者ID:dtkahl,项目名称:php-file-cache,代码行数:9,代码来源:FileCacheTest.php

示例2: getPackageDetails

 /**
  * Loads details about one or more packages.
  *
  * @param string|array $packages
  * @return array
  * @throws NotFoundHttpException if the package doesn't exist
  * @throws LoadingException if the package couldn't be loaded
  */
 public function getPackageDetails($packages)
 {
     $key = 'marketplace.details.' . implode('|', (array) $packages);
     return $this->cache->remember($key, 10, function () use($packages) {
         if (is_string($packages)) {
             return $this->getSinglePackageDetails($packages);
         } else {
             return $this->getMultiplePackageDetails($packages);
         }
     });
 }
开发者ID:noikiy,项目名称:mod-marketplace,代码行数:19,代码来源:PackagistLoader.php

示例3: read

 public static function read($group)
 {
     return Cache::remember('admin_config_' . $group, function () use($group) {
         $o = new Object();
         return $o->requestAction('/config/get/' . $group);
     }, 'admin_config');
 }
开发者ID:bramas,项目名称:cakephp2-admin,代码行数:7,代码来源:AdminConfig.php

示例4: index

 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $extras = Cache::remember('extras_global', 10, function () {
         return Extra::where('approved', '=', '1')->take(25)->orderBy('created_at')->get();
     });
     return View::make('extra.index_extra', array('extras' => $extras));
 }
开发者ID:Belar,项目名称:eventpotion,代码行数:12,代码来源:ExtraController.php

示例5: getRandTip

 public static function getRandTip()
 {
     $tips = Cache::remember(self::CACHE_KEY, self::CACHE_MINUTES, function () {
         return Tip::all();
     });
     return $tips->random();
 }
开发者ID:adminrt,项目名称:phphub,代码行数:7,代码来源:Tip.php

示例6: printTest

 public function printTest(Request $request)
 {
     $studentsDcid = $request->get('studentsdcid');
     $fileOption = $request->get('fileOption') ?: 'concat';
     $watermarkOption = $request->get('watermarkOption') ?: 'final';
     if ($studentsDcid) {
         $student = Student::where('dcid', $studentsDcid)->firstOrFail();
     } else {
         $student = \Cache::remember('printTestStudent', 1440, function () {
             return Student::orderByRaw('DBMS_RANDOM.RANDOM')->firstOrFail();
         });
     }
     $form = [(object) ['formid' => $request->get('formid'), 'title' => $request->get('title'), 'responseid' => $request->get('responseid')]];
     $cacheKey = 'printtestformdata' . $request->get('formid') . $request->get('responseid');
     $responses = \Cache::remember($cacheKey, 1440, function () use($form) {
         return Iep::getFormData($form);
     });
     $info = $this->dispatch(new PrintPdf($student, $responses, $fileOption, $watermarkOption));
     if (isset($_GET['html'])) {
         return $info;
     }
     if (!empty($info['file'])) {
         return '<h2><a target="_blank" href="' . asset($info['file']) . '">' . $info['file'] . '</a></h2>';
     }
     return $info;
 }
开发者ID:jamesprices,项目名称:iep-printing-php,代码行数:26,代码来源:FrameController.php

示例7: index

 /**
  * Display a listing of people
  *
  * @return Response
  */
 public function index()
 {
     $persons = Cache::remember('people', 1, function () {
         return DB::table('people')->get();
     });
     echo '<pre>';
     print_r($persons);
     echo '</pre>';
     /* Transaction::chunk(20, function($transactions)
     			{
     			    foreach ($transactions as $transaction)
     			    {
     			        //
     			        
     			    }
     			    echo "new lot </br>";
     			});
     
     	         echo '<pre>';
     	         print_r(DB::getQueryLog());
     	         echo '</pre>';
     	         */
     /*$child =  Child::with('institutes')->find(1);
     
     	         echo '<pre>';
     	         print_r($child->toArray());
     	         echo '</pre>';
                  */
 }
开发者ID:sharad23,项目名称:devtest-angular,代码行数:34,代码来源:PeopleController.php

示例8: isStoryteller

 public function isStoryteller()
 {
     return Cache::remember('user-storyteller-' . $this->id, 60, function () {
         $p_id = PermissionDefinition::where('name', 'Storyteller')->firstOrFail()->id;
         return $this->permissions()->where('permission_id', $p_id)->count() > 0;
     });
 }
开发者ID:AcceptableIce,项目名称:Larp3,代码行数:7,代码来源:User.php

示例9: cachedQuery

 /**
  * Обертка для кэширования запросов
  * @param $cache_key
  * @param \Closure $query
  * @return mixed
  */
 public function cachedQuery($cache_key, \Closure $query)
 {
     $cache_time = \Config::get('docs-api.cache_time');
     return \Cache::remember($cache_key, $cache_time, function () use($query) {
         return $query();
     });
 }
开发者ID:Snikius,项目名称:example,代码行数:13,代码来源:DocsApi.php

示例10: createListOfPages

 public function createListOfPages()
 {
     $this->data['items'] = $this->getElementsWhereHasModel('pages', 'tags', $this->tagId, app('veer')->siteId, array("take_pages" => $this->number_of_items), true)->select('id', 'url', 'title', 'small_txt', 'views', 'created_at', 'users_id')->orderBy('manual_order', 'desc')->get();
     $this->data['tagName'] = \Cache::remember('tagNameId' . $this->tagId, 2, function () {
         return \Veer\Models\Tag::where('id', '=', $this->tagId)->pluck('name');
     });
 }
开发者ID:artemsk,项目名称:veer-themes,代码行数:7,代码来源:indexCornersDigest.php

示例11: layout_version

 function layout_version($layout = 'main')
 {
     $get_hash = function ($layout) {
         $hash = '';
         $files = [public_path('assets/css/app.css'), public_path('assets/js/app.js'), resource_path('views/layouts/main.blade.php'), resource_path('views/partials/header.blade.php'), resource_path('views/partials/footer.blade.php')];
         if ($layout != 'main') {
             $files[] = resource_path('views/layouts/' . str_replace('.', DIRECTORY_SEPARATOR, $layout) . '.blade.php');
         }
         foreach ($files as $file) {
             $hash .= hash_file('md5', $file);
         }
         return hash('md5', $hash);
     };
     if (App::environment('local', 'development', 'staging')) {
         if (!($hash = config('version.layout.' . $layout))) {
             $hash = $get_hash($layout);
             config(compact('hash'));
         }
     } else {
         $hash = Cache::remember('version.layout.' . $layout, config('version.cache_duration', 5), function () use($get_hash, $layout) {
             return $get_hash($layout);
         });
     }
     return $hash;
 }
开发者ID:CupOfTea696,项目名称:CardsAgainstTea,代码行数:25,代码来源:helpers.php

示例12: buildRulebook

 public function buildRulebook($owner = -1)
 {
     //Build rulebook or retrieve it from the cache.
     $out = Cache::remember('rulebook', 24 * 60, function () {
         $baseRulebook = [];
         $baseRulebook['sects'] = $this->expandSects(RulebookSect::get());
         $baseRulebook['clans'] = $this->expandClans(RulebookClan::get());
         $baseRulebook['rituals'] = $this->sortByGroups(RulebookRitual::whereNull('owner')->get(), "rituals");
         $baseRulebook['backgrounds'] = $this->sortByGroups(RulebookBackground::orderBy('name')->get(), "backgrounds");
         $baseRulebook['disciplines'] = $this->expandDisciplines(RulebookDiscipline::orderBy('name')->get());
         $baseRulebook['natures'] = RulebookNature::get();
         $baseRulebook['abilities'] = $this->sortByGroups(RulebookAbility::where('owner', null)->orderBy('name')->get(), "abilities");
         $baseRulebook["paths"] = $this->expandPaths(RulebookPath::get());
         $baseRulebook["derangements"] = RulebookDerangement::get();
         $baseRulebook['merits'] = $this->sortByGroups(RulebookMerit::orderBy("cost")->get(), "merits");
         $baseRulebook['flaws'] = $this->sortByGroups(RulebookFlaw::orderBy("cost")->get(), "flaws");
         return $baseRulebook;
     });
     if ($owner != -1) {
         $out['custom_abilities'] = RulebookAbility::where('owner', $owner)->get();
         $out['elder_powers'] = RulebookElderPower::where('owner_id', $owner)->get();
         $out['combo_disciplines'] = RulebookComboDiscipline::where('owner_id', $owner)->get();
         $out['custom_rituals'] = RulebookRitual::where('owner', $owner)->get();
     }
     return Response::json($out);
 }
开发者ID:AcceptableIce,项目名称:Larp3,代码行数:26,代码来源:HomeController.php

示例13: showWeek

 /**
  * Generate the view of the week for given month and given year
  * with events in this period.
  *
  * @param string $year
  * @param string $week 
  * @return view weekView
  *
  *
  */
 public function showWeek($year, $week)
 {
     // Create week start date on monday (day 1)
     $weekStart = date('Y-m-d', strtotime($year . "W" . $week . '1'));
     // Create the number of the next week
     $nextWeek = date("W", strtotime("next Week" . $weekStart));
     $nextYear = date("Y", strtotime("next Week" . $weekStart));
     // Create week end date - we go till tuesday (day 2) because café needs alternative week view (Mi-Di)
     $weekEnd = date('Y-m-d', strtotime($nextYear . "W" . $nextWeek . '2'));
     // Create the number of the previous week
     $previousWeek = date("W", strtotime("previous Week" . $weekStart));
     $previousYear = date("Y", strtotime("previous Week" . $weekStart));
     // Convert number of prev/next week to verbatim format - needed for correct << and >> button links
     $nextWeek = $nextYear . "/KW" . $nextWeek;
     $previousWeek = $previousYear . "/KW" . $previousWeek;
     $date = array('year' => $year, 'week' => $week, 'weekStart' => $weekStart, 'weekEnd' => $weekEnd, 'nextWeek' => $nextWeek, 'previousWeek' => $previousWeek);
     $events = ClubEvent::where('evnt_date_start', '>=', $weekStart)->where('evnt_date_start', '<=', $weekEnd)->with('getPlace', 'getSchedule.getEntries.getJobType', 'getSchedule.getEntries.getPerson.getClub')->orderBy('evnt_date_start')->orderBy('evnt_time_start')->get();
     $tasks = Schedule::where('schdl_show_in_week_view', '=', '1')->where('schdl_due_date', '>=', $weekStart)->where('schdl_due_date', '<=', $weekEnd)->with('getEntries.getPerson.getClub', 'getEntries.getJobType')->get();
     // TODO: don't use raw query, rewrite with eloquent.
     $persons = Cache::remember('personsForDropDown', 10, function () {
         $timeSpan = new DateTime("now");
         $timeSpan = $timeSpan->sub(DateInterval::createFromDateString('3 months'));
         return Person::whereRaw("prsn_ldap_id IS NOT NULL \n\t\t\t\t\t\t\t\t\t\t AND (prsn_status IN ('aktiv', 'kandidat') \n\t\t\t\t\t\t\t\t\t\t OR updated_at>='" . $timeSpan->format('Y-m-d H:i:s') . "')")->orderBy('clb_id')->orderBy('prsn_name')->get();
     });
     $clubs = Club::orderBy('clb_title')->lists('clb_title', 'id');
     // IDs of schedules shown, needed for bulk-update
     $updateIds = array();
     foreach ($events as $event) {
         array_push($updateIds, $event->getSchedule->id);
     }
     return View::make('weekView', compact('events', 'schedules', 'date', 'tasks', 'entries', 'weekStart', 'weekEnd', 'persons', 'clubs'));
 }
开发者ID:gitter-badger,项目名称:lara-vedst,代码行数:42,代码来源:WeekController.php

示例14: ShowStaff

 /**
  * Show staff page
  * GET
  *
  * @return Response
  */
 public function ShowStaff()
 {
     $staffs = \Cache::remember('staff', 60, function () {
         return \App\Model\Staff::join('accounts', 'accounts.guid', '=', 'cms_staffs.account_id')->orderBy('rank', 'asc')->get();
     });
     return view('misc.staff', compact('staffs'));
 }
开发者ID:Synthx,项目名称:Acamar,代码行数:13,代码来源:MiscController.php

示例15: showHome

 /**
  * Show homepage
  * GET
  *
  * @return Response
  */
 public function showHome()
 {
     $blogs = \Cache::remember('blogs', 60, function () {
         return NewsManager::orderBy('date', 'desc')->take(6)->get();
     });
     return view('news.home', compact('blogs'));
 }
开发者ID:Synthx,项目名称:Acamar,代码行数:13,代码来源:NewsController.php


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