@@ -22,21 +22,12 @@ public function cache(array $tags = [])
22
22
}
23
23
24
24
if (is_subclass_of ($ cache ->getStore (), TaggableStore::class)) {
25
- $ tags = $ this ->addTagsWhenCalledFromCachedBuilder ($ tags );
26
25
$ cache = $ cache ->tags ($ tags );
27
26
}
28
27
29
28
return $ cache ;
30
29
}
31
30
32
- protected function addTagsWhenCalledFromCachedBuilder (array $ tags ) : array
33
- {
34
- $ usesCachableTrait = collect (class_uses ($ this ))
35
- ->contains ("GeneaLabs\LaravelModelCaching\Traits\Cachable " );
36
-
37
- return $ tags ;
38
- }
39
-
40
31
public function disableCache ()
41
32
{
42
33
$ this ->isCachable = false ;
@@ -99,30 +90,38 @@ protected function getModelCacheCooldown(Model $instance)
99
90
{
100
91
$ cachePrefix = $ this ->getCachePrefix ();
101
92
$ modelClassName = get_class ($ instance );
102
-
103
- $ cacheCooldown = $ instance
104
- ->cache ()
105
- ->get ("{$ cachePrefix }: {$ modelClassName }-cooldown:seconds " );
93
+ [$ cacheCooldown , $ invalidatedAt , $ savedAt ] = $ this
94
+ ->getCacheCooldownDetails ($ instance , $ cachePrefix , $ modelClassName );
106
95
107
96
if (! $ cacheCooldown ) {
108
97
return [null , null , null ];
109
98
}
110
99
111
- $ invalidatedAt = $ instance
112
- ->cache ()
113
- ->get ("{$ cachePrefix }: {$ modelClassName }-cooldown:invalidated-at " );
114
-
115
- $ savedAt = $ instance
116
- ->cache ()
117
- ->get ("{$ cachePrefix }: {$ modelClassName }-cooldown:saved-at " );
118
-
119
100
return [
120
101
$ cacheCooldown ,
121
102
$ invalidatedAt ,
122
103
$ savedAt ,
123
104
];
124
105
}
125
106
107
+ protected function getCacheCooldownDetails (
108
+ Model $ instance ,
109
+ string $ cachePrefix ,
110
+ string $ modelClassName
111
+ ) : array {
112
+ return [
113
+ $ instance
114
+ ->cache ()
115
+ ->get ("{$ cachePrefix }: {$ modelClassName }-cooldown:seconds " ),
116
+ $ instance
117
+ ->cache ()
118
+ ->get ("{$ cachePrefix }: {$ modelClassName }-cooldown:invalidated-at " ),
119
+ $ instance
120
+ ->cache ()
121
+ ->get ("{$ cachePrefix }: {$ modelClassName }-cooldown:saved-at " ),
122
+ ];
123
+ }
124
+
126
125
protected function checkCooldownAndRemoveIfExpired (Model $ instance )
127
126
{
128
127
[$ cacheCooldown , $ invalidatedAt ] = $ this ->getModelCacheCooldown ($ instance );
0 commit comments