/** * Compose the view. * * @return void */ public function compose(View $view) { $value = Cache::remember('users', 3, function () { return DB::table('users')->get(); }); $view->with('tags', Tags::all())->with('categories', Category::all()); }
/** * Tries to return all the cached permissions of the user * and if it can't bring the permissions from the cache, * it would bring them back from the DB * @return Illuminate\Database\Eloquent\Collection */ public function cachedPermissions() { $cacheKey = 'laratrust_permissions_for_user_' . $this->getKey(); return Cache::remember($cacheKey, Config::get('cache.ttl', 60), function () { return $this->permissions()->get(); }); }
function getContactInfo() { $contactInfo = Cache::remember('contactusInfo', 20, function () { return $this->first(); }); return $contactInfo; }
public static function karma() { $value = Cache::remember('statistics_karma', 5, function () { return Vote::count(); }); return $value; }
/** * 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); }); }
/** * Actions allowed to be used on reports * * @return array */ public function getActions() { $actions = Cache::remember('system.adkats.reports.actions', 60 * 12, function () { return Command::whereIn('command_id', static::$allowedCommands)->lists('command_name', 'command_id'); }); return $actions; }
/** * Bind data to the view. * * @param View $view * @return void */ public function compose(View $view) { $user = Cache::remember('user', 1440, function () { return Auth::user(); }); $view->with('user', $user); }
public function fetchAll() { $result = Cache::remember('post_cache', 1, function () { return $this->get(); }); return $result; }
/** * Tries to return all the cached roles of the user * and if it can't bring the roles from the cache, * it would bring them back from the DB * @return Illuminate\Database\Eloquent\Collection */ public function cachedRoles() { $cacheKey = 'lumineer_roles_for_user_' . $this->getKey(); return Cache::remember($cacheKey, Config::get('cache.ttl', 60), function () { return $this->roles()->get(); }); }
/** * Returns cached data after updating the cached value if expired * * @param string $key * @param int $ttl * @param closure $closure * @return mixed */ public static function remember($key, $ttl, $closure) { if (!isset(static::$cache[$key])) { static::$cache[$key] = parent::remember($key, $ttl, $closure); } return static::$cache[$key]; }
/** * Init blogit. * * Fetch all files on the Github repository, transform and store them into * a collection of articles. * * @return void */ protected function init() { if (config('blogit.cache')) { $documents = Cache::remember('documents', config('blogit.cache_expiration'), function () { return $this->documents->getAll(); }); } else { $documents = $this->documents->getAll(); } // Make and push the new article into the collection. foreach ($documents as $document) { if (config('blogit.cache')) { $article = Cache::remember($document['sha'], config('blogit.cache_expiration'), function () use($document) { return $this->makeArticle($document['path']); }); } else { $article = $this->makeArticle($document['path']); } $this->collection->push($article); } // Set the previous and next articles for each article. $this->collection = $this->collection->each(function ($article, $key) { if (($previous = $this->collection->get($key - 1)) instanceof Article) { $article->setPrevious($previous); } if (($next = $this->collection->get($key + 1)) instanceof Article) { $article->setNext($next); } }); // Set the related articles for each article. $this->collection = $this->collection->each(function ($article) { $related = $this->getRelatedArticlesByTags($article); $article->setRelatedArticles($related); }); }
/** * 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); }
/** * @param $marketId * * @return mixed */ public function getJson($marketId) { $ttl = Config::get('altwallets::calculation.trade_rate_ttl'); return Cache::remember('lasttradeprice.' . $marketId, $ttl, function () use($marketId) { return json_decode(file_get_contents($this->url . $marketId)); }); }
/** * Shows the player profile * * @param integer $id * @param string $name */ public function profile($id, $name = '') { // Cache key $key = sprintf('player.%u', $id); // Is there already a cached version for the player $isCached = Cache::has($key); // Get or Set cache for player $player = Cache::remember($key, 5, function () use($id) { $json = $this->repository->setopts(['ban.previous.server', 'ban.record.server', 'reputation', 'infractionsGlobal', 'infractionsServer.server', 'stats.server', 'specialGroups'], true)->getPlayerById($id)->toJson(); return json_decode($json); }); $charts = Cache::remember(sprintf('player.%u.charts', $id), 5, function () use($id) { $charts = []; $charts['overview'] = new Collection(DB::select(File::get(storage_path() . '/sql/playerCommandOverview.sql'), [$id])); $charts['spline'] = new Collection(DB::select(File::get(storage_path() . '/sql/playerCommandHistory.sql'), [$id])); $charts['aliases'] = Record::where('command_type', 48)->where('target_id', $id)->select(DB::raw('record_message AS `player_name`, COUNT(record_id) AS `seen`'))->groupBy('player_name')->get(); $charts['iphistory'] = Record::where('command_type', 49)->where('target_id', $id)->where('record_message', '!=', 'No previous IP on record')->select(DB::raw('record_message AS `ip`, COUNT(record_id) AS `seen`'))->groupBy('ip')->get(); $charts['overview'] = $charts['overview']->map(function ($command) { return [$command->label, intval($command->value)]; }); $charts['aliases'] = $charts['aliases']->map(function ($a) { return [$a->player_name, intval($a->seen)]; }); $charts['iphistory'] = $charts['iphistory']->map(function ($ip) { return [$ip->ip, intval($ip->seen)]; }); return $charts; }); $groups = MainHelper::specialGroups($player->special_groups, 'player_group'); $page_title = !empty($player->ClanTag) ? sprintf('[%s] %s', $player->ClanTag, $player->SoldierName) : $player->SoldierName; return View::make('player.profile', compact('player', 'page_title', 'charts', 'isCached', 'groups')); }
/** * 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; }
/** * Display a listing of the resource. * * @return Response */ public function index() { $makers = Cache::remember('makers', 15 / 60, function () { return Maker::simplePaginate(15); }); return response()->json(['next' => $makers->nextPageUrl(), 'previous' => $makers->previousPageUrl(), 'data' => $makers->items()], 200); }
protected function recent() { view()->composer('widgets.recent', function ($view) { $view->with('articles', Cache::remember('widgets_recent', 10, function () { return Article::with('tags', 'category')->public()->orderby('published_at', 'desc')->take(5)->get(); })); }); }
public function getTaskById($id) { // dd($id); $task = Cache::remember("task_{$id}", 60, function () use($id) { return self::findOrFail($id); }); return $task; }
public static function popular() { $populardata = Cache::remember('popular', 60, function () { $data = Content::take(15)->orderBy('pageview', 'desc')->get(); return $data; }); return $populardata; }
public function cachedPermissions() { //$rolePrimaryKey = $this->primaryKey; $cacheKey = 'entrust_permissions_for_role_' . $this->getKey(); return Cache::remember($cacheKey, Config::get('cache.ttl'), function () { return $this->perms()->get(); }); }
public function cachedRoles() { //$userPrimaryKey = $this->primaryKey; $cacheKey = 'entrust_roles_for_user_' . $this->getKey(); return Cache::remember($cacheKey, Config::get('cache.ttl'), function () { return $this->roles()->get(); }); }
public function getStateProvincesForCountry($countryId) { $key = 'stateprovince-' . $countryId; $stateProvinces = Cache::remember($key, config('app.cache_expiry_time_stateprovinces'), function () use($countryId) { return $this->dataAccess->getStateProvincesForCountry($countryId); }); return $stateProvinces; }
public function biletixJson() { $etkinlik_array = Cache::remember('biletlerHesaplanan', 10, function () { $bilet_listesi = file_get_contents('http://www.biletix.com/solr/tr/select/?start=0&rows=100&sort=start%20asc&&wt=json'); $etkinlik_array = json_decode($bilet_listesi, true); return $etkinlik_array; }); return view("biletixjson", ['etkinlik_array' => $etkinlik_array]); }
public function compose($view) { $nearby = Cache::remember('nearbyMissions', 60, function () { $nearby['past'] = Mission::past()->take(3)->get(); $nearby['future'] = Mission::future()->take(3)->get(); return $nearby; }); $view->with('nearbyMissions', ['past' => $nearby['past'], 'future' => $nearby['future']]); }
public function iplookup($addy) { $hash = md5($addy); $result = Cache::remember(sprintf('iplookup.%s', $hash), 24 * 60, function () use(&$addy) { $request = App::make('guzzle')->get("http://ipinfo.io/" . $addy . "/json"); return $request->json(); }); return $result; }
/** * 构建一个DBOperator对象 * @param string $table * @param string $key * @param string $meta_key default is 'iid' * @return DBOperator */ static function apply($table, $key = '', $meta_key = 'iid') { if (empty($key)) { $key = isset(self::$TABLE_PKEY[$table]) ? self::$TABLE_PKEY[$table] : 'id'; } $fields = Cache::remember('db.cache.' . $table . '.fields', 1, function () use($table) { return (new DBOperator($table, 'id'))->fields(); }); return new DBOperator($table, $key, $meta_key, $fields); }
/** * 分享页面 * @param $slug * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View */ public function share($slug) { $data = Cache::remember('com.tanteng.share.page.' . $slug, self::CACHE_TIME, function () use($slug) { $content = $this->content->getContent($slug); $content->content = Markdown::convertToHtml($content->content); return ['content' => $content]; }); $content = $data['content']; return view('content.page', compact('content')); }
/** * Show the settings dashboard. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function show(Request $request) { $data = ['activeTab' => $request->get('tab', Spark::firstSettingsTabKey()), 'invoices' => [], 'user' => $this->users->getCurrentUser()]; if (Auth::user()->stripe_id) { $data['invoices'] = Cache::remember('spark:invoices:' . Auth::id(), 30, function () { return Auth::user()->invoices(); }); } return view('settings.dashboard', $data); }
/** * Display a listing of the resource. * * @return Response */ public function index() { /** Add cache */ $transactions = Cache::remember('transaction_logs', 15 / 60, function () { return Transaction_log::with('user')->with('bank_account')->with('currency')->get(); //simplePaginate(10); }); // $transactions = Transaction_log::with('user')->with('bank_account')->with('currency')->get(); return response()->json(['data' => $transactions], 200); // return view('transaction.index')->with('transactions', $transactions); }
/** * Create or update a note * * @param Request $request * @return \Illuminate\Http\JsonResponse */ public function index(Request $request) { $linehaul = $request->input('linehaul', null); $postalCode = $request->input('postalcode', null); $fresh = $request->input('fresh', false); $dummy = $request->input('dummy', false); //Damn strings if ($fresh == 'false') { $fresh = false; } if ($fresh) { $postalCodes = $this->getPostalCodes($linehaul, $postalCode); } else { $postalCodes = Cache::remember('postal_codes', 24 * 60, function () use($linehaul, $postalCode) { return $this->getPostalCodes($linehaul, $postalCode); }); } if (!$dummy) { return Excel::create('PostalCodes' . Carbon::now()->toDateString(), function ($excel) use($postalCodes) { $excel->sheet('postalcodes', function ($sheet) use($postalCodes) { $sheet->fromArray($postalCodes); }); })->download('xls'); } return 'DB UPDATED'; }