Skip to content

Commit e45b5e2

Browse files
committed
Merge branch 'release/0.2.28'
2 parents 5629be0 + dc57d64 commit e45b5e2

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

CHANGELOG.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
55
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
66

7-
## [0.2.27] - 16 Feb 2018
7+
## [0.2.28] - 18 Feb 2018
8+
### Changed
9+
- disabling of cache from using session to use cache-key instead.
10+
11+
## [0.2.27] - 17 Feb 2018
812
### Fixed
913
- the erroneous use of `arrayEmpty()` function, changed to simple `count()`.
1014

src/Traits/Cachable.php

+7-4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
use GeneaLabs\LaravelModelCaching\CacheKey;
44
use GeneaLabs\LaravelModelCaching\CacheTags;
55
use GeneaLabs\LaravelModelCaching\CachedModel;
6+
use Illuminate\Support\Facades\Cache;
67
use Illuminate\Cache\TaggableStore;
78
use Illuminate\Database\Query\Builder;
89
use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
@@ -11,6 +12,7 @@
1112
trait Cachable
1213
{
1314
protected $isCachable = true;
15+
protected static $isCachableKey = 'genealabs:model-caching:is-disabled';
1416

1517
protected function cache(array $tags = [])
1618
{
@@ -33,7 +35,8 @@ protected function cache(array $tags = [])
3335

3436
public function disableCache()
3537
{
36-
session(['genealabs-laravel-model-caching-is-disabled' => true]);
38+
cache()->forever(self::$isCachableKey, true);
39+
3740
$this->isCachable = false;
3841

3942
return $this;
@@ -78,7 +81,7 @@ public static function bootCachable()
7881

7982
public static function all($columns = ['*'])
8083
{
81-
if (session('genealabs-laravel-model-caching-is-disabled')) {
84+
if (cache()->get(self::$isCachableKey)) {
8285
return parent::all($columns);
8386
}
8487

@@ -95,8 +98,8 @@ public static function all($columns = ['*'])
9598

9699
public function newEloquentBuilder($query)
97100
{
98-
if (session('genealabs-laravel-model-caching-is-disabled')) {
99-
session()->forget('genealabs-laravel-model-caching-is-disabled');
101+
if (cache()->get(self::$isCachableKey)) {
102+
cache()->forget(self::$isCachableKey);
100103

101104
return new EloquentBuilder($query);
102105
}

0 commit comments

Comments
 (0)