本文整理汇总了PHP中Illuminate\Contracts\Cache\Repository::remember方法的典型用法代码示例。如果您正苦于以下问题:PHP Repository::remember方法的具体用法?PHP Repository::remember怎么用?PHP Repository::remember使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Contracts\Cache\Repository
的用法示例。
在下文中一共展示了Repository::remember方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: resolve
/**
* @param $name
*
* @return Sidebar
*/
public function resolve($name)
{
$duration = $this->config->get('sidebar.cache.duration');
return $this->cache->remember(CacheKey::get($name), $duration, function () use($name) {
return $this->resolver->resolve($name);
});
}
示例2: get
/**
* Get the collaborators for a repo.
*
* @param \StyleCI\StyleCI\Models\Repo $repo
*
* @return int[]
*/
public function get(Repo $repo)
{
// cache the collaborator info from github for 12 hours
return $this->cache->remember("{$repo->id}collaborators", 720, function () use($repo) {
return $this->fetchFromGitHub($repo->user, $repo->name);
});
}
示例3: getComposerFile
/**
* Get the decoded contents from the main composer.json file
* @return object
*/
private function getComposerFile()
{
$composerFile = $this->cache->remember('app.version', 1440, function () {
return $this->filesystem->get('composer.json');
});
return json_decode($composerFile);
}
示例4: __call
/**
*
*/
public function __call($method, $params)
{
if (!method_exists($this->repository, $method)) {
throw new RepositoryException("Method {$method} not found on repository");
}
if ($this->skipCache === true || config('laravel-database.cache') === false) {
return call_user_func_array(array($this->repository, $method), $params);
} else {
if (empty($this->key)) {
$this->cacheKey($this->generateKey($method, $params));
}
$key = $this->key;
unset($this->key);
if ($this->refreshCache) {
$this->cache->forget($key);
$this->refreshCache = false;
}
if (empty($this->lifetime)) {
$this->cacheLifetime($this->repository->getModel()->cacheLifetime());
}
$lifetime = $this->lifetime;
unset($this->lifetime);
return $this->cache->remember($key, $lifetime, function () use($method, $params) {
return call_user_func_array(array($this->repository, $method), $params);
});
}
}
示例5: get
/**
* Get an item from the storage.
*
* @param string $key
*
* @return string|null
*/
public function get($key)
{
$data = $this->cache->remember("store.{$key}", 30, function () use($key) {
return $this->store->get($key);
});
if ($data) {
return $data;
}
}
示例6: performQuery
/**
* Query the Google Analytics Service with given parameters.
*
* @param string $viewId
* @param \DateTime $startDate
* @param \DateTime $endDate
* @param string $metrics
* @param array $others
*
* @return array|null
*/
public function performQuery(string $viewId, DateTime $startDate, DateTime $endDate, string $metrics, array $others = [])
{
$cacheName = $this->determineCacheName(func_get_args());
if ($this->cacheLifeTimeInMinutes == 0) {
$this->cache->forget($cacheName);
}
return $this->cache->remember($cacheName, $this->cacheLifeTimeInMinutes, function () use($viewId, $startDate, $endDate, $metrics, $others) {
return $this->service->data_ga->get("ga:{$viewId}", $startDate->format('Y-m-d'), $endDate->format('Y-m-d'), $metrics, $others);
});
}
示例7: get
/**
* Get the given documentation page.
*
* @param string $version
* @param string $page
* @return string
*/
public function get($version, $page)
{
return $this->cache->remember('docs.' . $version . '.' . $page, 5, function () use($version, $page) {
$path = base_path('resources/docs/' . $page . '.md');
if ($this->files->exists($path)) {
return $this->replaceLinks($version, markdown($this->files->get($path)));
}
return null;
});
}
示例8: latest
/**
* Returns the latest release.
*
* @return string
*/
public function latest()
{
$release = $this->cache->remember('release.latest', 720, function () {
$headers = ['Accept' => 'application/vnd.github.v3+json', 'User-Agent' => defined('CACHET_VERSION') ? 'cachet/' . constant('CACHET_VERSION') : 'cachet'];
if ($this->token) {
$headers['OAUTH-TOKEN'] = $this->token;
}
return json_decode((new Client())->get($this->url, ['headers' => $headers])->getBody(), true);
});
return ['tag_name' => $release['tag_name'], 'prelease' => $release['prerelease'], 'draft' => $release['draft']];
}
示例9: latest
/**
* Returns the latest credits.
*
* @return array|null
*/
public function latest()
{
$result = $this->cache->remember('credits', 2880, function () {
try {
return json_decode((new Client())->get($this->url, ['headers' => ['Accept' => 'application/json', 'User-Agent' => defined('CACHET_VERSION') ? 'cachet/' . constant('CACHET_VERSION') : 'cachet']])->getBody(), true);
} catch (Exception $e) {
return self::FAILED;
}
});
return $result === self::FAILED ? null : $result;
}
示例10: getPaginated
/**
* Get a cached paginated list of all users
*
* @param int $howMany
*
* @param string $byFirstname
*
* @return mixed
*/
public function getPaginated($howMany = 10, $byFirstname = null)
{
$this->howMany = $howMany;
$this->byFirstname = $byFirstname;
if (!$this->byFirstname) {
return $this->cache->remember('users.all', 20, function () {
});
} else {
return $this->repository->getPaginated($this->howMany, $this->byFirstname);
}
}
示例11: get
/**
* Get the form.
*
* @return FormPresenter
*/
public function get()
{
$this->fire('ready', ['criteria' => $this]);
array_set($this->parameters, 'key', md5(json_encode($this->parameters)));
array_set($this->parameters, 'options.url', array_get($this->parameters, 'options.url', $this->builder->getOption('url', 'form/handle/' . array_get($this->parameters, 'key'))));
$this->cache->remember('form::' . array_get($this->parameters, 'key'), 30, function () {
return $this->parameters;
});
$this->hydrator->hydrate($this->builder, $this->parameters);
return (new Decorator())->decorate($this->builder->make()->getForm());
}
示例12: latest
/**
* Returns the latest entries.
*
* @return array|null
*/
public function latest()
{
$result = $this->cache->remember('feeds', 720, function () {
try {
$xml = simplexml_load_string((new Client())->get($this->url, ['headers' => ['Accept' => 'application/rss+xml', 'User-Agent' => defined('CACHET_VERSION') ? 'cachet/' . constant('CACHET_VERSION') : 'cachet']])->getBody()->getContents(), null, LIBXML_NOCDATA);
return json_decode(json_encode($xml));
} catch (Exception $e) {
return self::FAILED;
}
});
return $result === self::FAILED ? null : $result;
}
示例13: get
/**
* Get the given documentation page.
*
* @param string $version
* @param string $page
*
* @return string
*/
public function get($version, $page)
{
return $this->cache->remember('docs.' . $version . '.' . $page, $this->cacheTime, function () use($version, $page) {
$path = $this->fullPagePath($version, $page);
if ($this->files->exists($path)) {
$content = $this->replaceLinks($version, markdown($this->files->get($path)));
$title = $content ? $this->getDocTitleByContent($content) : null;
return compact('content', 'title');
}
return null;
});
}
示例14: get
/**
* Get a user's repos.
*
* @param \StyleCI\StyleCI\Models\User $user
* @param bool $admin
*
* @return array
*/
public function get(User $user, $admin = false)
{
// cache the repo info from github for 12 hours
$list = $this->cache->remember($user->id . 'repos', 720, function () use($user) {
return $this->fetchFromGitHub($user);
});
foreach (Repo::whereIn('id', array_keys($list))->get() as $repo) {
$list[$repo->id]['enabled'] = true;
$this->syncWithDatabase($repo, $list[$repo->id]);
}
return $list;
}
示例15: latest
/**
* Returns the latest GitHub release.
*
* @return string
*/
public function latest()
{
$release = $this->cache->remember('version', 720, function () {
$headers = ['Accept' => 'application/vnd.github.v3+json'];
// We can re-use the Emoji token here, if we have it.
if ($token = $this->config->get('services.github.token')) {
$headers['OAUTH-TOKEN'] = $token;
}
return json_decode((new Client())->get('https://api.github.com/repos/cachethq/cachet/releases/latest', ['headers' => $headers])->getBody(), true);
});
return $release['tag_name'];
}