@@ -17,9 +17,12 @@ public function avg($column)
1717 }
1818
1919 return $ this ->cache ($ this ->makeCacheTags ())
20- ->rememberForever ($ this ->makeCacheKey () . "-avg_ {$ column }" , function () use ($ column ) {
21- return parent ::avg ($ column );
22- });
20+ ->rememberForever (
21+ $ this ->makeCacheKey (['* ' ], null , "-avg_ {$ column }" ),
22+ function () use ($ column ) {
23+ return parent ::avg ($ column );
24+ }
25+ );
2326 }
2427
2528 public function count ($ columns = ['* ' ])
@@ -29,9 +32,12 @@ public function count($columns = ['*'])
2932 }
3033
3134 return $ this ->cache ($ this ->makeCacheTags ())
32- ->rememberForever ($ this ->makeCacheKey () . "-count " , function () use ($ columns ) {
33- return parent ::count ($ columns );
34- });
35+ ->rememberForever (
36+ $ this ->makeCacheKey (['* ' ], null , "-count " ),
37+ function () use ($ columns ) {
38+ return parent ::count ($ columns );
39+ }
40+ );
3541 }
3642
3743 public function cursor ()
@@ -41,9 +47,12 @@ public function cursor()
4147 }
4248
4349 return $ this ->cache ($ this ->makeCacheTags ())
44- ->rememberForever ($ this ->makeCacheKey () . "-cursor " , function () {
45- return collect (parent ::cursor ());
46- });
50+ ->rememberForever (
51+ $ this ->makeCacheKey (['* ' ], null , "-cursor " ),
52+ function () {
53+ return collect (parent ::cursor ());
54+ }
55+ );
4756 }
4857
4958 public function delete ()
@@ -64,9 +73,12 @@ public function find($id, $columns = ['*'])
6473 }
6574
6675 return $ this ->cache ($ this ->makeCacheTags ())
67- ->rememberForever ($ this ->makeCacheKey ($ columns , $ id ), function () use ($ id , $ columns ) {
68- return parent ::find ($ id , $ columns );
69- });
76+ ->rememberForever (
77+ $ this ->makeCacheKey ($ columns , $ id ),
78+ function () use ($ id , $ columns ) {
79+ return parent ::find ($ id , $ columns );
80+ }
81+ );
7082 }
7183
7284 public function first ($ columns = ['* ' ])
@@ -76,9 +88,12 @@ public function first($columns = ['*'])
7688 }
7789
7890 return $ this ->cache ($ this ->makeCacheTags ())
79- ->rememberForever ($ this ->makeCacheKey ($ columns ) . '-first ' , function () use ($ columns ) {
80- return parent ::first ($ columns );
81- });
91+ ->rememberForever (
92+ $ this ->makeCacheKey ($ columns , null , '-first ' ),
93+ function () use ($ columns ) {
94+ return parent ::first ($ columns );
95+ }
96+ );
8297 }
8398
8499 public function get ($ columns = ['* ' ])
@@ -88,9 +103,12 @@ public function get($columns = ['*'])
88103 }
89104
90105 return $ this ->cache ($ this ->makeCacheTags ())
91- ->rememberForever ($ this ->makeCacheKey ($ columns ), function () use ($ columns ) {
92- return parent ::get ($ columns );
93- });
106+ ->rememberForever (
107+ $ this ->makeCacheKey ($ columns ),
108+ function () use ($ columns ) {
109+ return parent ::get ($ columns );
110+ }
111+ );
94112 }
95113
96114 public function max ($ column )
@@ -100,9 +118,12 @@ public function max($column)
100118 }
101119
102120 return $ this ->cache ($ this ->makeCacheTags ())
103- ->rememberForever ($ this ->makeCacheKey () . "-max_ {$ column }" , function () use ($ column ) {
104- return parent ::max ($ column );
105- });
121+ ->rememberForever (
122+ $ this ->makeCacheKey (['* ' ], null , "-max_ {$ column }" ),
123+ function () use ($ column ) {
124+ return parent ::max ($ column );
125+ }
126+ );
106127 }
107128
108129 public function min ($ column )
@@ -112,9 +133,12 @@ public function min($column)
112133 }
113134
114135 return $ this ->cache ($ this ->makeCacheTags ())
115- ->rememberForever ($ this ->makeCacheKey () . "-min_ {$ column }" , function () use ($ column ) {
116- return parent ::min ($ column );
117- });
136+ ->rememberForever (
137+ $ this ->makeCacheKey (['* ' ], null , "-min_ {$ column }" ),
138+ function () use ($ column ) {
139+ return parent ::min ($ column );
140+ }
141+ );
118142 }
119143
120144 public function pluck ($ column , $ key = null )
@@ -123,11 +147,8 @@ public function pluck($column, $key = null)
123147 return parent ::pluck ($ column , $ key );
124148 }
125149
126- $ cacheKey = $ this ->makeCacheKey ([$ column ]) . "-pluck_ {$ column }" ;
127-
128- if ($ key ) {
129- $ cacheKey .= "_ {$ key }" ;
130- }
150+ $ keyDifferentiator = "-pluck_ {$ column }" . ($ key ? "_ {$ key }" : "" );
151+ $ cacheKey = $ this ->makeCacheKey ([$ column ], null , $ keyDifferentiator );
131152
132153 return $ this ->cache ($ this ->makeCacheTags ())
133154 ->rememberForever ($ cacheKey , function () use ($ column , $ key ) {
@@ -142,9 +163,12 @@ public function sum($column)
142163 }
143164
144165 return $ this ->cache ($ this ->makeCacheTags ())
145- ->rememberForever ($ this ->makeCacheKey () . "-sum_ {$ column }" , function () use ($ column ) {
146- return parent ::sum ($ column );
147- });
166+ ->rememberForever (
167+ $ this ->makeCacheKey (['* ' ], null , "-sum_ {$ column }" ),
168+ function () use ($ column ) {
169+ return parent ::sum ($ column );
170+ }
171+ );
148172 }
149173
150174 public function value ($ column )
@@ -154,8 +178,11 @@ public function value($column)
154178 }
155179
156180 return $ this ->cache ($ this ->makeCacheTags ())
157- ->rememberForever ($ this ->makeCacheKey () . "-value_ {$ column }" , function () use ($ column ) {
158- return parent ::value ($ column );
159- });
181+ ->rememberForever (
182+ $ this ->makeCacheKey (['* ' ], null , "-value_ {$ column }" ),
183+ function () use ($ column ) {
184+ return parent ::value ($ column );
185+ }
186+ );
160187 }
161188}
0 commit comments