本文整理汇总了PHP中Illuminate\Cache\Repository::get方法的典型用法代码示例。如果您正苦于以下问题:PHP Repository::get方法的具体用法?PHP Repository::get怎么用?PHP Repository::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Cache\Repository
的用法示例。
在下文中一共展示了Repository::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: tryFetchResultFromCache
/**
* @param Builder $qb
* @param array $attributes
* @return LengthAwarePaginator|Collection|null
*/
public function tryFetchResultFromCache(Builder $qb, array $attributes = [])
{
$this->generateQueryHashFromQueryBuilder($qb, $attributes);
if ($this->cache->has($this->actualQueryHash)) {
return $this->cache->get($this->actualQueryHash);
}
return null;
}
示例2: fire
/**
* Execute the console command.
*
* @return mixed
*/
public function fire()
{
$types = $this->config->get('assets.types');
$oldVersion = $this->cache->get('laravel-asset-versioning.version');
$version = Carbon::now()->timestamp;
$this->updateConfigVersion($version);
$this->unlinkOldDirectories($types, $oldVersion);
$this->createDistDirectories($types, $version);
}
示例3: testShouldReturnNullFlushRecord
public function testShouldReturnNullFlushRecord()
{
$this->repository->add('memcached-testing', 'couchbase', 60);
$this->repository->decrement('memcached-testing-decrement', 100);
$this->repository->increment('memcached-testing-increment', 100);
$this->repository->flush();
$this->assertNull($this->repository->get('memcached-testing'));
$this->assertNull($this->repository->get('memcached-testing-decrement'));
$this->assertNull($this->repository->get('memcached-testing-increment'));
}
示例4: fetch
/**
* {@inheritdoc}
*/
public function fetch($key)
{
try {
$cache = unserialize($this->cache->get($key));
if ($cache instanceof CacheEntry) {
return $cache;
}
} catch (\Exception $ignored) {
return;
}
return;
}
示例5: loginWithToken
/**
* Verify the existence of the given user token.
*
* @param string $token
*
* @return \Fahita\Contracts\UserInterface|null
*/
public function loginWithToken($token)
{
if ($this->verifyToken($token)) {
$id = $this->cache->get($this->getCacheKey($token));
$attributes = $this->redis->hgetall('users:' . $id);
$user = (new User())->newInstance($attributes, true);
// creating a new instance does not include the record id
// but we want it, so we force fill it to fulfill it.
$user->forceFill($attributes);
return $this->login($user);
}
}
示例6: get
/**
* Retrieve an item from the cache by key.
*
* @param mixed $key
* @param mixed $default
* @return mixed
*/
public function get($key, $default = null)
{
if (is_array($key)) {
return $this->getMany($key, $default);
}
return parent::get($key, $default);
}
示例7: postAuthorized
/**
* Handles authenticating that a user/character is still valid.
*
* @return \Illuminate\Http\JsonResponse
*/
public function postAuthorized()
{
// Get the neccessary headers from the request.
$service = $this->request->header('service', false);
$username = $this->request->header('username', '');
$character = $this->request->header('character', '');
$this->log->info('A service is attempting to validate a user.', ['username' => $username, 'character' => $character, 'service' => $service]);
// Verify that the external service exists in the configuration.
if (!$service || !$this->config->get("addon.auth.{$service}")) {
$this->log->info(self::ERROR_INVALID_EXTERNAL_SERVICE, ['service' => $service]);
return $this->failure(self::ERRNO_INVALID_EXTERNAL_SERVICE, self::ERROR_INVALID_EXTERNAL_SERVICE);
}
// Check the cache first so the api isn't hammered too badly.
$key = 'auth:session:' . sha1("{$service}:{$username}");
if ($this->cache->has($key)) {
$this->log->info('Returning the cached authorization result.');
return $this->cache->get($key);
}
// Attempt to find the requested user.
$identifier = filter_var($username, FILTER_VALIDATE_EMAIL) ? 'email' : 'name';
$user = $this->users->where($identifier, $username)->first() ?: false;
if (!$user) {
$this->log->info(self::ERROR_USER_NOT_FOUND);
return $this->failure(self::ERRNO_USER_NOT_FOUND, self::ERROR_USER_NOT_FOUND);
}
// Get and cache the response for 15 minutes.
$response = $this->getLoginResult($user, $service, $character);
$this->cache->put($key, $response, $this->carbon->now()->addMinutes(15));
return $response;
}
示例8: get
/**
* Retrieve an item from the cache by key. If the item is about to expire soon,
* extend the existing cache entry (for other requests) before returning the item
*
* @param string $key
* @param mixed $default
* @return mixed
*/
public function get($key, $default = null)
{
while ($this->cacheFlagExists($key)) {
sleep($this->sleep);
}
return parent::get($key, $default);
}
示例9: getInstalledThemes
/**
* Retrives the installed themes from the cache.
*
* If the cahce entry doesn't exist then it is created.
*
* @return array
*/
public function getInstalledThemes()
{
$installed = $this->cache->get($this->cacheKey);
if ($installed !== null) {
return $installed;
}
return $this->findAndInstallThemes();
}
示例10: makeCacheKey
/**
* make a cache key
*
* @param string $key
* @param string $prefix
* @return string
*/
private function makeCacheKey($key, $prefix = '')
{
$key = md5($prefix . $key);
$keys = $this->cache->get(self::CACHE_KEYS_KEY, []);
$keys[$key] = $key;
$this->cache->forever(self::CACHE_KEYS_KEY, $keys);
return $key;
}
示例11: getRealmData
/**
* @return Realm
*/
public function getRealmData()
{
$that = $this;
return $this->cache->get('ekko:static:realm', function () use($that) {
$data = $this->ekko->data()->getRealm();
$that->cache->add('ekko:static:realm', $data, 60 * 24 * 7);
return $data;
});
}
示例12: image
public function image(Repository $cache, $id)
{
if ($cache->has($id)) {
return $cache->get($id);
}
$card = base64_encode(file_get_contents('http://magiccards.info/scans/en/ori/' . $id . '.jpg'));
$cache->put($id, $card, 60);
return $card;
}
示例13: saveCachedView
/**
* Save a cached view if caching is enabled.
*
* @param \Illuminate\Http\Response $response
* @return void
*/
protected function saveCachedView(Response $response)
{
if (config('sitemap.cache_enabled')) {
$key = $this->getCacheKey();
$content = $response->getOriginalContent()->render();
if (!$this->cache->get($key)) {
$this->cache->put($key, $content, config('sitemap.cache_length'));
}
}
}
示例14: getMatch
/**
* @param $matchId
*
* @return Match
*/
public function getMatch($matchId)
{
$that = $this;
$cachKey = 'match:' . $matchId;
return $this->cache->get($cachKey, function () use($that, $cachKey, $matchId) {
$match = $that->ekko->matches()->getMatch($matchId, true);
$match = $that->setStaticData($match);
$that->cache->put('match:' . $matchId, $match, 3600);
return $match;
});
}
示例15: replaceVersion
public function replaceVersion($path)
{
$version = $this->cache->get('laravel-asset-versioning.version');
$file = explode('.', $path);
$extension = $file[count($file) - 1];
$types = $this->config->get('assets.types.' . $extension);
if (isset($types['origin_dir'])) {
$types = [$types];
}
foreach ((array) $types as $type) {
if (!$type) {
continue;
}
if (!preg_match("#^\\/?" . $type['origin_dir'] . "#", $path)) {
continue;
}
$resource = str_replace($type['origin_dir'], $type['dist_dir'] . '/' . $version, $path);
$this->addHTTP2Link($resource, $extension);
return $resource;
}
return $path;
}