Ejemplo n.º 1
0
 /**
  * @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;
 }
Ejemplo n.º 2
0
 /**
  * Determine if an item exists in the cache.
  *
  * @param  mixed  $key
  * @return mixed
  */
 public function has($key)
 {
     if (is_array($key)) {
         return $this->hasMany($key);
     }
     return parent::has($key);
 }
Ejemplo n.º 3
0
 /**
  * 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;
 }
Ejemplo n.º 4
0
 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;
 }
Ejemplo n.º 5
0
 /**
  * Check to see whether a view has already been cached for the current
  * route and if so, return it.
  *
  * @return mixed
  */
 protected function getCachedView()
 {
     if (config('sitemap.cache_enabled')) {
         $key = $this->getCacheKey();
         if ($this->cache->has($key)) {
             return $this->cache->get($key);
         }
     }
     return false;
 }
Ejemplo n.º 6
0
 /**
  * Determine if an item exists in the cache.
  *
  * @param string $key
  * @return bool 
  * @static 
  */
 public static function has($key)
 {
     return \Illuminate\Cache\Repository::has($key);
 }
 /**
  * @param string $key
  *
  * @return bool
  */
 public function has($key)
 {
     return $this->cache->has($key);
 }
Ejemplo n.º 8
0
 /**
  * Verify the given token for a valid user.
  *
  * @param  string $token
  *
  * @return boolean
  */
 public function verifyToken($token)
 {
     return $this->cache->has($this->getCacheKey($token));
 }
Ejemplo n.º 9
0
 /**
  * @param $key
  * @return bool
  */
 public function has($key)
 {
     return $this->enabled ? $this->cache->has($key) : false;
 }
 /**
  * Determine if an item exists in the cache.
  *
  * @param  string $key
  * @return bool
  */
 public function has($key)
 {
     if (!$this->operatingOnKeywords()) {
         $this->resetCurrentKeywords();
     }
     return parent::has($key);
 }
Ejemplo n.º 11
0
 /**
  * 캐싱된 플러그인 정보가 있는지 조사한다.
  *
  * @return bool
  */
 public function hasCachedPlugins()
 {
     return $this->cache->has($this->cacheKey);
 }
 /**
  * isExistCachedSiteInstanceRoutes
  *
  * @param string $siteKey key of to confirm exist site instance routes
  *
  * @return bool
  */
 public function isExistCachedSiteInstanceRoutes($siteKey)
 {
     if ($this->debugMode) {
         return false;
     }
     $keyString = $this->getSiteCacheKeyString($siteKey);
     return $this->cache->has($keyString);
 }
Ejemplo n.º 13
0
 /**
  * Check a setting exists in cache
  *
  * @param string $key
  *
  * @return boolean
  */
 public function cacheHas($key)
 {
     return $this->cache->has($this->attachTag($key)) ? true : false;
 }
Ejemplo n.º 14
0
 /**
  * Check if cache entry exists
  *
  * @param string $key
  *
  * @return bool
  */
 public function hasItem($key)
 {
     $key = $this->getKey($key);
     return $this->cacheRepository->has($key);
 }