@@ -34,10 +34,6 @@ protected function addTagsWhenCalledFromCachedBuilder(array $tags) : array
3434 $ usesCachableTrait = collect (class_uses ($ this ))
3535 ->contains ("GeneaLabs\LaravelModelCaching\Traits\Cachable " );
3636
37- if (! $ usesCachableTrait ) {
38- array_push ($ tags , str_slug (get_called_class ()));
39- }
40-
4137 return $ tags ;
4238 }
4339
@@ -59,10 +55,7 @@ public function flushCache(array $tags = [])
5955 [$ cacheCooldown ] = $ this ->getModelCacheCooldown ($ this );
6056
6157 if ($ cacheCooldown ) {
62- $ cachePrefix = "genealabs:laravel-model-caching: "
63- . (config ('laravel-model-caching.cache-prefix ' )
64- ? config ('laravel-model-caching.cache-prefix ' , '' ) . ": "
65- : "" );
58+ $ cachePrefix = $ this ->getCachePrefix ();
6659 $ modelClassName = get_class ($ this );
6760 $ cacheKey = "{$ cachePrefix }: {$ modelClassName }-cooldown:saved-at " ;
6861
@@ -157,7 +150,7 @@ protected function checkCooldownAndRemoveIfExpired(Model $instance)
157150
158151 protected function checkCooldownAndFlushAfterPersiting (Model $ instance )
159152 {
160- [$ cacheCooldown , $ invalidatedAt, $ savedAt ] = $ instance ->getModelCacheCooldown ($ instance );
153+ [$ cacheCooldown , $ invalidatedAt ] = $ instance ->getModelCacheCooldown ($ instance );
161154
162155 if (! $ cacheCooldown ) {
163156 $ instance ->flushCache ();
@@ -167,19 +160,14 @@ protected function checkCooldownAndFlushAfterPersiting(Model $instance)
167160
168161 $ this ->setCacheCooldownSavedAtTimestamp ($ instance );
169162
170- if ($ savedAt > $ invalidatedAt
171- && now ()->diffInSeconds ($ invalidatedAt ) >= $ cacheCooldown
172- ) {
163+ if (now ()->diffInSeconds ($ invalidatedAt ) >= $ cacheCooldown ) {
173164 $ instance ->flushCache ();
174165 }
175166 }
176167
177168 protected function setCacheCooldownSavedAtTimestamp (Model $ instance )
178169 {
179- $ cachePrefix = "genealabs:laravel-model-caching: "
180- . (config ('laravel-model-caching.cache-prefix ' )
181- ? config ('laravel-model-caching.cache-prefix ' , '' ) . ": "
182- : "" );
170+ $ cachePrefix = $ this ->getCachePrefix ();
183171 $ modelClassName = get_class ($ instance );
184172 $ cacheKey = "{$ cachePrefix }: {$ modelClassName }-cooldown:saved-at " ;
185173
@@ -235,10 +223,7 @@ public function scopeWithCacheCooldownSeconds(
235223 EloquentBuilder $ query ,
236224 int $ seconds
237225 ) : EloquentBuilder {
238- $ cachePrefix = "genealabs:laravel-model-caching: "
239- . (config ('laravel-model-caching.cache-prefix ' )
240- ? config ('laravel-model-caching.cache-prefix ' , '' ) . ": "
241- : "" );
226+ $ cachePrefix = $ this ->getCachePrefix ();
242227 $ modelClassName = get_class ($ this );
243228 $ cacheKey = "{$ cachePrefix }: {$ modelClassName }-cooldown:seconds " ;
244229
0 commit comments