Example #1
0
 /**
  * Get info from a specify url and cache that using laravel cache manager.
  *
  * @param  string       $url
  * @param  null|array   $options
  * @return mixed
  */
 public function cache($url, array $options = null)
 {
     $lifetime = array_get($options, 'lifetime', 60);
     array_forget($options, 'lifetime');
     $self = $this;
     return $this->cache->remember($url, $lifetime, function () use($self, $url, $options) {
         return $self->get($url, $options);
     });
 }
 /**
  * Empty all views linked to a tag or the complete partial cache.
  * Note: Only supported by Taggable cache drivers.
  *
  * @param string $tag
  *
  * @throws \Spatie\PartialCache\Exceptions\MethodNotSupportedException
  */
 public function flush($tag = null)
 {
     if (!$this->cacheIsTaggable) {
         throw new MethodNotSupportedException('The cache driver (' . get_class($this->cacheManager->driver()) . ') doesn\'t support the flush method.');
     }
     $tag = $tag ?: $this->cacheKey;
     $this->cache->tags($tag)->flush();
 }
Example #3
0
 /**
  * Make a new store.
  *
  * @param array $config
  *
  * @throws \InvalidArgumentException
  *
  * @return \AltThree\Storage\Stores\StoreInterface
  */
 public function make(array $config)
 {
     $config = $this->getConfig($config);
     $store = new FlysystemStore($this->flysystem->connection($config['main']));
     if ($config['fallback']) {
         $store = new FallbackStore($store, new FlysystemStore($this->flysystem->connection($config['fallback'])));
     }
     if ($config['compression']) {
         $store = new CompressingStore($store, $this->compressor);
     }
     if ($config['encryption']) {
         if ($config['compression']) {
             throw new InvalidArgumentException('Compression cannot be enabled at the same time as encryption.');
         }
         $store = new EncryptingStore($store, $this->encrypter);
     }
     if ($cache = $config['cache']) {
         $store = new CachingStore($store, $this->cache->store($cache === true ? null : $cache));
     }
     return $store;
 }
 /**
  * Get the cache client.
  *
  * @param string[] $config
  *
  * @return \Illuminate\Contracts\Cache\Store
  */
 protected function getClient(array $config)
 {
     $name = array_get($config, 'connector');
     return $this->cache->driver($name)->getStore();
 }
 /**
  * Construct a new File loader.
  *
  * @param  \Illuminate\Contracts\Foundation\Application  $app
  * @param  \Illuminate\Contracts\Cache\Repository  $cache
  * @param  \Illuminate\Filesystem\Filesystem  $files
  */
 public function __construct(Application $app, Cache $cache, Filesystem $files)
 {
     $this->app = $app;
     $this->cache = $cache->driver('file');
     $this->files = $files;
 }
 /**
  * @param array $settings
  *
  * @return MemcachedCache
  */
 public function resolve(array $settings = [])
 {
     return new IlluminateCacheAdapter($this->cache->store('memcached'));
 }
 public function __construct(CacheFactory $cacheFactory, array $config)
 {
     $this->_cache = $cacheFactory->store($config['cache']);
 }
 public function __construct(CacheFactory $cacheFactory, RuleProvider $ruleProvider, array $config)
 {
     $this->_cache = $cacheFactory->store($config['cache']);
     $this->_ruleProvider = $ruleProvider;
 }