@@ -50,6 +50,11 @@ Be sure to not require a specific version of this package when requiring it:
50
50
composer require genealabs/laravel-model-caching:*
51
51
```
52
52
53
+ ## Upgrade Notes
54
+ ### 0.5.0
55
+ The following implementations have changed (see the respective sections below):
56
+ - model-specific cache prefix
57
+
53
58
## Configuration
54
59
### Recommended (Optional) Custom Cache Store
55
60
If you would like to use a different cache store than the default one used by
@@ -99,10 +104,6 @@ prefixing to keep cache entries separate for multi-tenant applications. For this
99
104
it is recommended to add the Cachable trait to a base model, then set the cache
100
105
key prefix config value there.
101
106
102
- ** Note that the config setting is included before the parent method is called,
103
- so that the setting is available in the parent as well. If you are developing a
104
- multi-tenant application, see the note above.**
105
-
106
107
Here's is an example:
107
108
``` php
108
109
<?php namespace GeneaLabs\LaravelModelCaching\Tests\Fixtures;
@@ -116,15 +117,16 @@ class BaseModel extends Model
116
117
{
117
118
use Cachable;
118
119
119
- public function __construct($attributes = [])
120
- {
121
- config(['laravel-model-caching.cache-prefix' => 'test-prefix']);
122
-
123
- parent::__construct($attributes);
124
- }
120
+ protected $cachePrefix = "test-prefix";
125
121
}
126
122
```
127
123
124
+ The cache prefix can also be set in the configuration to prefix all cached
125
+ models across the board:
126
+ ``` php
127
+ 'cache-prefix' => 'test-prefix',
128
+ ```
129
+
128
130
### Exception: User Model
129
131
I would not recommend caching the user model, as it is a special case, since it
130
132
extends ` Illuminate\Foundation\Auth\User ` . Overriding that would break functionality.
0 commit comments