本文整理汇总了PHP中Illuminate\Contracts\Cache\Repository类的典型用法代码示例。如果您正苦于以下问题:PHP Repository类的具体用法?PHP Repository怎么用?PHP Repository使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Repository类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
开发者ID:framgia,项目名称:laravel-jwt,代码行数:12,代码来源:CacheStorage.php
示例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;
}
开发者ID:fordongu,项目名称:maigc-menubar,代码行数:13,代码来源:SupportsCacheTags.php
示例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);
});
}
}
开发者ID:ablunier,项目名称:laravel-database,代码行数:30,代码来源:Cache.php
示例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));
}
}
开发者ID:ShuvarthiDhar,项目名称:tobacco,代码行数:7,代码来源:BaseCache.php
示例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;
}
开发者ID:rodrigopedra,项目名称:russian-doll-caching,代码行数:14,代码来源:RussianDollCaching.php
示例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);
}
开发者ID:Houbsi,项目名称:Core,代码行数:11,代码来源:ApplicationVersionViewComposer.php
示例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);
});
}
开发者ID:fordongu,项目名称:maigc-menubar,代码行数:12,代码来源:StaticCacheResolver.php
示例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');
}
开发者ID:ronaldcastillo,项目名称:brightcove,代码行数:10,代码来源:BrightCoveCacheDecorator.php
示例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;
});
}
开发者ID:kylestev,项目名称:tor-info,代码行数:12,代码来源:CacheTorIPs.php
示例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')]]);
}
开发者ID:anouarabdsslm,项目名称:micro-service,代码行数:7,代码来源:TicketController.php
示例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'));
}
开发者ID:4mb,项目名称:pi.strebl.ch,代码行数:17,代码来源:WelcomeController.php
示例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();
});
}
开发者ID:znck,项目名称:trust,代码行数:14,代码来源:Trust.php
示例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;
}
开发者ID:bedemiralp,项目名称:InfinityCache,代码行数:15,代码来源:Builder.php
示例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;
});
}
开发者ID:boomcms,项目名称:boom-core,代码行数:10,代码来源:BoomCMS.php
示例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;
}
开发者ID:disik69,项目名称:backend.english-roulette-v0.3,代码行数:10,代码来源:Captcha.php
示例16: 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;
});
}
开发者ID:ifromz,项目名称:deploy-cloud,代码行数:17,代码来源:Documentation.php
示例17: 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);
});
}
开发者ID:spatie,项目名称:laravel-analytics,代码行数:21,代码来源:AnalyticsClient.php
示例18: resolve
/**
* @param $name
*
* @return Sidebar
*/
public function resolve($name)
{
if ((new SupportsCacheTags())->isSatisfiedBy($this->cache)) {
$userId = $this->guard->check() ? $this->guard->user()->getAuthIdentifier() : null;
$duration = $this->config->get('sidebar.cache.duration');
return $this->cache->tags(CacheKey::get($name))->remember(CacheKey::get($name, $userId), $duration, function () use($name) {
return $this->resolver->resolve($name);
});
}
}
开发者ID:fordongu,项目名称:maigc-menubar,代码行数:15,代码来源:UserBasedCacheResolver.php
示例19: __call
/**
* @param $name
* @param $arguments
* @return mixed
*/
public function __call($name, $arguments)
{
/*
* simple strategy: for any database altering method we do the following:
* - call the parent method
* - bust the cache
*/
$result = call_user_func_array([$this->menu, $name], $arguments);
$this->cache->forget('menus');
return $result;
}
开发者ID:jaffle-be,项目名称:framework,代码行数:16,代码来源:CachedMenuRepository.php
示例20: all
/**
* Get the dataset collection
*
* @return \Illuminate\Support\Collection
*/
public function all()
{
$cacheKey = 'dataset' . (new ReflectionClass($this))->getShortName();
if ($this->cache->has($cacheKey)) {
return $this->cache->get($cacheKey);
}
$dataset = $this->cache->rememberForever($cacheKey, function () {
return $this->getDataset();
});
return $dataset;
}
开发者ID:TFidryForks,项目名称:spira,代码行数:16,代码来源:Dataset.php
注:本文中的Illuminate\Contracts\Cache\Repository类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论