Skip to content

Commit

Permalink
Adjust cache handling
Browse files Browse the repository at this point in the history
Bugfix
  • Loading branch information
marcreichel committed Jun 23, 2019
1 parent ac7aace commit a144abd
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.idea/
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"keywords": ["laravel", "api-wrapper", "igdb", "igdb-api", "apicalypse", "wrapper"],
"require": {
"php": "^7.1.3",
"laravel/framework": "5.7.*|5.8.*",
"laravel/framework": "5.8.*",
"guzzlehttp/guzzle": "~6.0",
"ext-json": "*"
},
Expand Down
5 changes: 3 additions & 2 deletions config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@

/*
* This package caches queries automatically.
* Here you can set how long each query should be cached.
* Here you can set how long (in seconds) each query should be cached (by
* default).
*
* To turn cache off set this value to 0
*/
'cache_lifetime' => env('IGDB_CACHE_LIFETIME', 60),
'cache_lifetime' => env('IGDB_CACHE_LIFETIME', 3600),

/*
* This is the per-page limit for your tier ("Free" by default)
Expand Down
10 changes: 5 additions & 5 deletions src/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ public function where(
$value = null,
$boolean = '&'
) {
if (is_callable($key)) {
if ($key instanceof Closure) {
return $this->whereNested($key, $boolean);
}

Expand Down Expand Up @@ -1284,13 +1284,13 @@ public function with(array $relationships)
/**
* Overwrite the cache lifetime for this query.
*
* @param int $minutes
* @param mixed $seconds
*
* @return $this
*/
public function cache(int $minutes): self
public function cache($seconds): self
{
$this->cacheLifetime = $minutes;
$this->cacheLifetime = $seconds;

return $this;
}
Expand Down Expand Up @@ -1406,7 +1406,7 @@ public function get()

$cacheKey = 'igdb_cache.' . md5($this->endpoint . $this->getQuery());

if (!$this->cacheLifetime) {
if (is_int($this->cacheLifetime) && $this->cacheLifetime === 0) {
Cache::forget($cacheKey);
}

Expand Down

0 comments on commit a144abd

Please sign in to comment.