Skip to content

Commit

Permalink
Fixed DateTime issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
rennokki committed Dec 14, 2019
1 parent 21d1321 commit 3daf6a9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
1 change: 0 additions & 1 deletion src/Query/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Rennokki\QueryCache\Query;

use DateTime;
use Illuminate\Database\Query\Builder as BaseBuilder;
use Rennokki\QueryCache\Contracts\QueryCacheModuleInterface;
use Rennokki\QueryCache\Traits\QueryCacheModule;
Expand Down
10 changes: 5 additions & 5 deletions src/Traits/QueryCacheModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

namespace Rennokki\QueryCache\Traits;

use Carbon\Carbon;
use DateTime;

trait QueryCacheModule
{
/**
* The number of seconds or the DateTime instance
* that specifies how long to cache the query.
*
* @var int|\DateTime|\Carbon\Carbon
* @var int|\DateTime
*/
protected $cacheTime;

Expand Down Expand Up @@ -69,7 +69,7 @@ public function getFromQueryCache(string $method = 'get', $columns = ['*'])
$callback = $this->getQueryCacheCallback($method, $columns);
$time = $this->getCacheTime();

if ($time instanceof DateTime || $time instanceof Carbon || $time > 0) {
if ($time instanceof DateTime || $time > 0) {
return $cache->remember($key, $time, $callback);
}

Expand Down Expand Up @@ -188,7 +188,7 @@ public function flushQueryCacheWithTag(string $tag): bool
/**
* Indicate that the query results should be cached.
*
* @param \DateTime|\Carbon\Carbon|int $time
* @param \DateTime|int $time
* @return \Rennokki\QueryCache\Query\Builder
*/
public function cacheFor($time)
Expand Down Expand Up @@ -329,7 +329,7 @@ public function shouldUsePlainKey(): bool
/**
* Get the cache time attribute.
*
* @return int|\DateTime|\Carbon\Carbon
* @return int|\DateTime
*/
public function getCacheTime()
{
Expand Down

0 comments on commit 3daf6a9

Please sign in to comment.