@@ -50,6 +50,11 @@ Be sure to not require a specific version of this package when requiring it:
5050composer require genealabs/laravel-model-caching:*
5151```
5252
53+ ## Upgrade Notes
54+ ### 0.5.0
55+ The following implementations have changed (see the respective sections below):
56+ - model-specific cache prefix
57+
5358## Configuration
5459### Recommended (Optional) Custom Cache Store
5560If 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
99104it is recommended to add the Cachable trait to a base model, then set the cache
100105key prefix config value there.
101106
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-
106107Here's is an example:
107108``` php
108109<?php namespace GeneaLabs\LaravelModelCaching\Tests\Fixtures;
@@ -116,15 +117,16 @@ class BaseModel extends Model
116117{
117118 use Cachable;
118119
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";
125121}
126122```
127123
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+
128130### Exception: User Model
129131I would not recommend caching the user model, as it is a special case, since it
130132extends ` Illuminate\Foundation\Auth\User ` . Overriding that would break functionality.
0 commit comments