Skip to content

Commit

Permalink
Allow disabling cache
Browse files Browse the repository at this point in the history
  • Loading branch information
antonioribeiro committed Aug 24, 2016
1 parent e4dac47 commit bf6d246
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/Support/Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ public function __construct(Config $config, Application $app)

public function cachePut($cacheKey, $model)
{
IlluminateCache::put($cacheKey, $model, 10);
if ($this->config->get('cache_enabled'))
{
IlluminateCache::put($cacheKey, $model, 10);
}
}

private function extractAttributes($attributes)
Expand Down Expand Up @@ -68,7 +71,10 @@ private function extractKeys($attributes, $keys)
*/
public function findCachedWithKey($key)
{
return IlluminateCache::get($key);
if ($this->config->get('cache_enabled'))
{
return IlluminateCache::get($key);
}
}

public function makeKeyAndPut($model, $key)
Expand All @@ -80,6 +86,11 @@ public function makeKeyAndPut($model, $key)

public function findCached($attributes, $keys, $identifier = null)
{
if (! $this->config->get('cache_enabled'))
{
return null;
}

$key = $this->makeCacheKey($attributes, $keys, $identifier);

return [
Expand Down

0 comments on commit bf6d246

Please sign in to comment.