Skip to content

Commit eb31752

Browse files
committed
Change environment variable MODEL_CACHE_DISABLED to MODEL_CACHE_ENABLED to better conform to standards
Fixes #266
1 parent fd6d007 commit eb31752

File tree

8 files changed

+18
-11
lines changed

8 files changed

+18
-11
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@ 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.6.0] - 2019-07-20
8+
### Changed
9+
- environment variable `MODEL_CACHE_DISABLED` to `MODEL_CACHE_ENABLED` to better conform to standards.
10+
11+
### Fixed
12+
- how cache key is constructed for SQLite.
13+
714
## [0.5.6] - 2019-06-20
815
### Removed
916
- all use of helper methods to allow non-Laravel apps to use this package:

config/laravel-model-caching.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
return [
44
'cache-prefix' => '',
55

6-
'disabled' => env('MODEL_CACHE_DISABLED', false),
6+
'enabled' => env('MODEL_CACHE_ENABLED', true),
77

88
'store' => env('MODEL_CACHE_STORE'),
99
];

src/Helper.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,17 @@ public function runDisabled(callable $closure)
88
{
99
$originalSetting = Container::getInstance()
1010
->make("config")
11-
->get('laravel-model-caching.disabled');
11+
->get('laravel-model-caching.enabled');
1212

1313
Container::getInstance()
1414
->make("config")
15-
->set(['laravel-model-caching.disabled' => true]);
15+
->set(['laravel-model-caching.enabled' => false]);
1616

1717
$result = $closure();
1818

1919
Container::getInstance()
2020
->make("config")
21-
->set(['laravel-model-caching.disabled' => $originalSetting]);
21+
->set(['laravel-model-caching.enabled' => $originalSetting]);
2222

2323
return $result;
2424
}

src/Traits/Caching.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,9 +270,9 @@ protected function checkCooldownAndFlushAfterPersisting(Model $instance, string
270270

271271
public function isCachable() : bool
272272
{
273-
$isCacheDisabled = Container::getInstance()
273+
$isCacheDisabled = ! Container::getInstance()
274274
->make("config")
275-
->get("laravel-model-caching.disabled");
275+
->get("laravel-model-caching.enabled");
276276

277277
return $this->isCachable
278278
&& ! $isCacheDisabled;

tests/Integration/CachedModelTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public function testScopeDisablesCachingWhenCalledOnModel()
6565

6666
public function testScopeDisableCacheDoesntCrashWhenCachingIsDisabledInConfig()
6767
{
68-
config(['laravel-model-caching.disabled' => true]);
68+
config(['laravel-model-caching.enabled' => false]);
6969
$key = sha1("genealabs:laravel-model-caching:testing:{$this->testingSqlitePath}testing.sqlite:test-prefix:authors:genealabslaravelmodelcachingtestsfixturesauthor");
7070
$tags = ["genealabs:laravel-model-caching:testing:{$this->testingSqlitePath}testing.sqlite:test-prefix:genealabslaravelmodelcachingtestsfixturesauthor"];
7171
$authors = (new PrefixedAuthor)
@@ -83,14 +83,14 @@ public function testScopeDisableCacheDoesntCrashWhenCachingIsDisabledInConfig()
8383

8484
public function testAllMethodCachingCanBeDisabledViaConfig()
8585
{
86-
config(['laravel-model-caching.disabled' => true]);
86+
config(['laravel-model-caching.enabled' => false]);
8787
$authors = (new Author)
8888
->all();
8989
$key = sha1("genealabs:laravel-model-caching:testing:{$this->testingSqlitePath}testing.sqlite:authors:genealabslaravelmodelcachingtestsfixturesauthor");
9090
$tags = [
9191
"genealabs:laravel-model-caching:testing:{$this->testingSqlitePath}testing.sqlite:genealabslaravelmodelcachingtestsfixturesauthor",
9292
];
93-
config(['laravel-model-caching.disabled' => false]);
93+
config(['laravel-model-caching.enabled' => true]);
9494

9595
$cachedResults = $this
9696
->cache()

tests/Integration/Traits/CachableTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public function testAllReturnsCollection()
7979

8080
public function testsCacheFlagDisablesCaching()
8181
{
82-
config(['laravel-model-caching.disabled' => true]);
82+
config(['laravel-model-caching.enabled' => false]);
8383

8484
$authors = (new Author)->get();
8585
$cachedAuthors = $this
@@ -89,7 +89,7 @@ public function testsCacheFlagDisablesCaching()
8989
])
9090
->get(sha1("genealabs:laravel-model-caching:testing:{$this->testingSqlitePath}testing.sqlite:authors:genealabslaravelmodelcachingtestsfixturesauthor-authors.deleted_at_null"));
9191

92-
config(['laravel-model-caching.disabled' => false]);
92+
config(['laravel-model-caching.enabled' => true]);
9393

9494
$this->assertNull($cachedAuthors);
9595
$this->assertNotEmpty($authors);

tests/database/baseline.sqlite

-8 KB
Binary file not shown.

tests/database/testing.sqlite

-8 KB
Binary file not shown.

0 commit comments

Comments
 (0)