Skip to content

Commit a6503ba

Browse files
committed
Implement disabling of cache using cache-key instead of session
1 parent 46643a0 commit a6503ba

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

src/Traits/Cachable.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212
trait Cachable
1313
{
1414
protected $isCachable = true;
15-
16-
protected static $isCachableKey = 'genealabs:model-caching:is-disabled';
15+
protected static $isCachableKey = 'genealabs:model-caching:is-disabled';
1716

1817
protected function cache(array $tags = [])
1918
{
@@ -36,7 +35,7 @@ protected function cache(array $tags = [])
3635

3736
public function disableCache()
3837
{
39-
Cache::forever(static::$isCachableKey, true);
38+
cache()->forever(self::$isCachableKey, true);
4039

4140
$this->isCachable = false;
4241

@@ -82,9 +81,9 @@ public static function bootCachable()
8281

8382
public static function all($columns = ['*'])
8483
{
85-
if (Cache::get(static::$isCachableKey)) {
84+
if (cache()->get(self::$isCachableKey)) {
8685
return parent::all($columns);
87-
}
86+
}
8887

8988
$class = get_called_class();
9089
$instance = new $class;
@@ -99,8 +98,8 @@ public static function all($columns = ['*'])
9998

10099
public function newEloquentBuilder($query)
101100
{
102-
if (Cache::get(static::$isCachableKey)) {
103-
Cache::forget(static::$isCachableKey);
101+
if (cache()->get(self::$isCachableKey)) {
102+
cache()->forget(self::$isCachableKey);
104103

105104
return new EloquentBuilder($query);
106105
}

0 commit comments

Comments
 (0)