本文整理汇总了PHP中Illuminate\Contracts\Cache\Repository::get方法的典型用法代码示例。如果您正苦于以下问题:PHP Repository::get方法的具体用法?PHP Repository::get怎么用?PHP Repository::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Contracts\Cache\Repository
的用法示例。
在下文中一共展示了Repository::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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');
}
示例2: getItem
/**
* {@inheritdoc}
*/
public function getItem($key)
{
$this->validateKey($key);
if ($this->repository->has($key)) {
return new CacheItem($key, unserialize($this->repository->get($key)), true);
} else {
return new CacheItem($key);
}
}
示例3: 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;
});
}
示例4: 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;
}
示例5: 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;
}
示例6: getTeamInfo
/**
* @return array
*/
public function getTeamInfo()
{
/**
* @var array|null $cached
*/
$cached = $this->cache->get(self::SLACK_TEAM_INFO_KEY);
if (!$cached) {
$cached = $this->refreshTeamInfo();
}
return $cached;
}
示例7: getItem
/**
* {@inheritdoc}
*/
public function getItem($key)
{
$this->validateKey($key);
if (isset($this->deferred[$key])) {
return clone $this->deferred[$key];
} elseif ($this->repository->has($key)) {
return new CacheItem($key, unserialize($this->repository->get($key)), true);
} else {
return new CacheItem($key);
}
}
示例8: performRealTimeQuery
/**
* Query the Google Analytics Real Time Reporting Service with given parameters.
*
* @param int $id
* @param string $metrics
* @param array $others
*
* @return mixed
*/
public function performRealTimeQuery($id, $metrics, array $others = [])
{
$realTimeCacheName = $this->determineRealTimeCacheName(func_get_args());
if ($this->useRealTimeCache() && $this->cache->has($realTimeCacheName)) {
return $this->cache->get($realTimeCacheName);
}
$googleAnswer = $this->service->data_realtime->get($id, $metrics, $others);
if ($this->useRealTimeCache()) {
$this->cache->put($realTimeCacheName, $googleAnswer, Carbon::now()->addSeconds($this->realTimeCacheLifeTimeInSeconds));
}
return $googleAnswer;
}
示例9: retrieveById
/**
* @param mixed $identifier
* @return \Illuminate\Contracts\Auth\Authenticatable|null
*/
public function retrieveById($identifier)
{
$cacheKey = "user:{$identifier}";
if ($this->cache->has($cacheKey)) {
return $this->cache->get($cacheKey);
}
$result = $this->createModel()->newQuery()->find($identifier);
if (is_null($result)) {
return null;
}
$this->cache->add($cacheKey, $result, 120);
return $result;
}
示例10: load
protected function load()
{
// load from cache
if ($this->cache) {
$map = $this->cache->get('vat-rates');
}
// fetch from jsonvat.com
if (empty($map)) {
$map = $this->fetch();
// store in cache
if ($this->cache) {
$this->cache->put('vat-rates', $map, 86400);
}
}
return $map;
}
示例11: getBranchesToSync
public function getBranchesToSync()
{
$allowedBranches = $this->setting('sync.constraints.branches');
if (count($allowedBranches) === 0) {
return [];
}
$this->fire('git.syncer.branches.start', [$allowedBranches]);
$branchesToSync = [];
$remote = $this->client($this->setting('remote'));
$repo = $this->setting('repository');
$owner = $this->setting('owner');
$branches = $remote->getBranches($repo, $owner);
foreach ($branches as $branch => $sha) {
if (!in_array('*', $allowedBranches, true) and !in_array($branch, $allowedBranches, true)) {
continue;
}
$cacheKey = md5($this->project->getName() . $branch);
$cached = $this->cache->get($cacheKey, false);
$destinationPath = Path::join($this->project->getPath(), $branch);
if ($cached !== $sha || $cached === false || !$this->files->exists($destinationPath)) {
$branchesToSync[] = $branch;
}
}
$this->fire('git.syncer.branches.finish', [$branchesToSync]);
return $branchesToSync;
}
示例12: getTimestampRestartCommand
/**
* Get the last restart timestamp, or null.
*
* @return int|null
*/
protected function getTimestampRestartCommand()
{
if ($this->cache) {
return $this->cache->get(self::restartID);
}
return null;
}
示例13: handle
/**
* Handle the command.
*
* @param Repository $cache
* @param Request $request
* @param UserAuthenticator $authenticator
* @param SettingRepositoryInterface $settings
* @param ThrottleSecurityCheckExtension $extension
* @return bool
*/
public function handle(Repository $cache, Request $request, UserAuthenticator $authenticator, SettingRepositoryInterface $settings, ThrottleSecurityCheckExtension $extension)
{
$maxAttempts = $settings->value('anomaly.extension.throttle_security_check::max_attempts', 5);
$lockoutInterval = $settings->value('anomaly.extension.throttle_security_check::lockout_interval', 1);
$throttleInterval = $settings->value('anomaly.extension.throttle_security_check::throttle_interval', 1);
$attempts = $cache->get($extension->getNamespace('attempts:' . $request->ip()), 1);
$expiration = $cache->get($extension->getNamespace('expiration:' . $request->ip()));
if ($expiration || $attempts >= $maxAttempts) {
$cache->put($extension->getNamespace('attempts:' . $request->ip()), $attempts + 1, $throttleInterval);
$cache->put($extension->getNamespace('expiration:' . $request->ip()), time(), $lockoutInterval);
$authenticator->logout();
// Just for safe measure.
return $this->dispatch(new MakeResponse());
}
$cache->put($extension->getNamespace('attempts:' . $request->ip()), $attempts + 1, $throttleInterval);
return true;
}
示例14: getProfileFromWatson
/**
* Get Full Insights From Watson API.
*
* @throws \FindBrok\WatsonBridge\Exceptions\WatsonBridgeException
*
* @return \Illuminate\Support\Collection
*/
public function getProfileFromWatson()
{
//We have the request in cache and cache is on
if ($this->cacheIsOn() && $this->cache->has($this->getContainer()->getCacheKey())) {
//Return results from cache
return $this->cache->get($this->getContainer()->getCacheKey());
}
//Cross the bridge
$response = $this->makeBridge()->post('v2/profile', $this->getContainer()->getContentsForRequest());
//Decode profile
$profile = collect(json_decode($response->getBody()->getContents(), true));
//Cache results if cache is on
if ($this->cacheIsOn()) {
$this->cache->put($this->getContainer()->getCacheKey(), $profile, $this->cacheLifetime());
}
//Return profile
return $profile;
}
示例15: retrieveById
/**
* Authコンポーネントのuser()メソッドなどを利用した場合に実行されるメソッドです
* デフォルトの場合、user()メソッドコール時に都度SQLが発行されますので、cacheを利用します。
* ユーザー情報更新時などにcacheを再生成するように実装します。
*
* @param mixed $identifier
*
* @return \Illuminate\Contracts\Auth\Authenticatable|null
*/
public function retrieveById($identifier)
{
/**
* user:$identifier(user_id) としてキャッシュを検索し、
* 見つからない場合は作成してデータベースから取得したデータを保持します
* 以降はデータベースへアクセスしません
*/
$cacheKey = "user:{$identifier}";
if ($this->cache->has($cacheKey)) {
return $this->cache->get($cacheKey);
}
$result = $this->createModel()->newQuery()->find($identifier);
if (is_null($result)) {
return null;
}
$this->cache->add($cacheKey, $result, 120);
return $result;
}