本文整理汇总了PHP中Illuminate\Contracts\Cache\Repository类的典型用法代码示例。如果您正苦于以下问题:PHP Repository类的具体用法?PHP Repository怎么用?PHP Repository使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Repository类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: cache
/**
* Return the cache instance with tags attached.
*
* @return \Illuminate\Contracts\Cache\Repository|\Illuminate\Contracts\Cache\Store
*/
protected function cache()
{
if (!method_exists($this->cache, 'tags')) {
return $this->cache;
}
return $this->cache->tags($this->tag);
}
示例2: isSatisfiedBy
/**
* @param Repository $repository
*
* @throws CacheTagsNotSupported
* @return bool
*/
public function isSatisfiedBy(Repository $repository)
{
if (!method_exists($repository->getStore(), 'tags')) {
throw new CacheTagsNotSupported('Cache tags are necessary to use this kind of caching. Consider using a different caching method');
}
return true;
}
示例3: __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);
});
}
}
示例4: update
public function update($id, array $attribute)
{
if ($this->model->update($id, $attribute)) {
$this->cache->forget($this->getKey('all'));
$this->cache->forget($this->getKey('id-' . $id));
}
}
示例5: getCache
/**
* Returns the current cache instance
*
* @param array $tags
*
* @return Cache
*/
protected function getCache(array $tags)
{
if ($this->cache instanceof TaggableStore) {
return $this->cache->tags(array_merge(['russian'], $tags));
}
return $this->cache;
}
示例6: 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);
}
示例7: 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);
});
}
示例8: authenticate
/**
* @return string Access token
*/
public function authenticate()
{
if (!$this->repository->has('brightcove.bearer')) {
$this->repository->put('brightcove.bearer', $this->brightcove->authenticate(), $this->duration);
}
return $this->repository->get('brightcove.bearer');
}
示例9: handle
/**
* Execute the console command.
*
* @return mixed
*/
public function handle(Cache $cache)
{
$ips = $this->fetchExitNodeIPs()->map(function ($ip) use($cache) {
$cache->tags(config('torinfo.caching.tags'))->put($ip, true, config('torinfo.caching.expiry'));
return $ip;
});
}
示例10: stats
public function stats(Cache $cache)
{
if (!$cache->has('tickets.total') && !$cache->has('tickets.open')) {
return $this->responseNoteFound('No stats found');
}
return $this->respond(['tickets' => ['open' => $cache->get('tickets.open'), 'total' => $cache->get('tickets.total')]]);
}
示例11: gettingStarted
/**
* Show the getting started screen to the user.
*
* @param MarkdownParser $markdown
* @param Cache $cache
* @param Filesystem $file
*
* @return Response
*/
public function gettingStarted(MarkdownParser $markdown, Cache $cache, Filesystem $file)
{
$gettingStarted = $cache->remember('getting-started', 5, function () use($markdown, $file) {
$gettingStarted = $file->get(base_path('resources/getting-started/readme.md'));
return $markdown->parse($gettingStarted);
});
return view('getting-started')->with(compact('gettingStarted'));
}
示例12: roles
/**
* @param bool $forget
*
* @return \Illuminate\Database\Eloquent\Collection|Role[]|null
*/
public function roles(bool $forget = false)
{
if ($forget === true) {
return $this->cache->forget(self::ROLE_KEY);
}
return $this->cache->rememberForever(self::ROLE_KEY, function () {
return app(Role::class)->with('permissions')->get();
});
}
示例13: get
/**
* Execute the query as a "select" statement.
*
* @param array $columns
* @return array|static[]
*/
public function get($columns = ['*'])
{
$cacheKey = $this->generateCacheKey();
if (null === ($results = $this->cache->tags($this->cacheTag)->get($cacheKey))) {
$results = parent::get($columns);
$this->cache->tags($this->cacheTag)->forever($cacheKey, $results);
}
return $results;
}
示例14: getNews
public function getNews()
{
$key = 'boomcms.news';
return $this->cache->get($key, function () use($key) {
$response = json_decode(@file_get_contents($this->newsUrl));
$news = $response->news ?? [];
$this->cache->put($key, $news, 3600);
return $news;
});
}
示例15: check
public function check($value)
{
$result = false;
if ($this->store->has('captcha')) {
$captchaStore = $this->store->get('captcha');
$result = $captchaStore->check($value);
$this->store->forever('captcha', $captchaStore);
}
return $result;
}