@@ -16,11 +16,9 @@ public function avg($column)
16
16
return parent ::avg ($ column );
17
17
}
18
18
19
- $ arguments = func_get_args ();
20
19
$ cacheKey = $ this ->makeCacheKey (["* " ], null , "-avg_ {$ column }" );
21
- $ method = "avg " ;
22
20
23
- return $ this ->cachedValue ($ arguments , $ cacheKey, $ method );
21
+ return $ this ->cachedValue (func_get_args () , $ cacheKey );
24
22
}
25
23
26
24
public function count ($ columns = ["* " ])
@@ -29,24 +27,9 @@ public function count($columns = ["*"])
29
27
return parent ::count ($ columns );
30
28
}
31
29
32
- $ arguments = func_get_args ();
33
- $ cacheKey = $ this ->makeCacheKey (["* " ], null , "-count " );
34
- $ method = "count " ;
30
+ $ cacheKey = $ this ->makeCacheKey ($ columns , null , "-count " );
35
31
36
- return $ this ->cachedValue ($ arguments , $ cacheKey , $ method );
37
- }
38
-
39
- public function cursor ()
40
- {
41
- if (! $ this ->isCachable ()) {
42
- return collect (parent ::cursor ());
43
- }
44
-
45
- $ arguments = func_get_args ();
46
- $ cacheKey = $ this ->makeCacheKey (["* " ], null , "-cursor " );
47
- $ method = "cursor " ;
48
-
49
- return $ this ->cachedValue ($ arguments , $ cacheKey , $ method );
32
+ return $ this ->cachedValue (func_get_args (), $ cacheKey );
50
33
}
51
34
52
35
public function delete ()
@@ -66,11 +49,9 @@ public function find($id, $columns = ["*"])
66
49
return parent ::find ($ id , $ columns );
67
50
}
68
51
69
- $ arguments = func_get_args ();
70
- $ cacheKey = $ this ->makeCacheKey (["* " ], null , "-find_ {$ id }" );
71
- $ method = "find " ;
52
+ $ cacheKey = $ this ->makeCacheKey ($ columns , null , "-find_ {$ id }" );
72
53
73
- return $ this ->cachedValue ($ arguments , $ cacheKey, $ method );
54
+ return $ this ->cachedValue (func_get_args () , $ cacheKey );
74
55
}
75
56
76
57
public function first ($ columns = ["* " ])
@@ -79,11 +60,9 @@ public function first($columns = ["*"])
79
60
return parent ::first ($ columns );
80
61
}
81
62
82
- $ arguments = func_get_args ();
83
63
$ cacheKey = $ this ->makeCacheKey ($ columns );
84
- $ method = "first " ;
85
64
86
- return $ this ->cachedValue ($ arguments , $ cacheKey, $ method );
65
+ return $ this ->cachedValue (func_get_args () , $ cacheKey );
87
66
}
88
67
89
68
public function get ($ columns = ["* " ])
@@ -92,11 +71,16 @@ public function get($columns = ["*"])
92
71
return parent ::get ($ columns );
93
72
}
94
73
95
- $ arguments = func_get_args ();
96
74
$ cacheKey = $ this ->makeCacheKey ($ columns );
97
- $ method = "get " ;
98
75
99
- return $ this ->cachedValue ($ arguments , $ cacheKey , $ method );
76
+ return $ this ->cachedValue (func_get_args (), $ cacheKey );
77
+ }
78
+
79
+ public function insert (array $ values )
80
+ {
81
+ $ this ->checkCooldownAndFlushAfterPersiting ($ this ->model );
82
+
83
+ return parent ::insert ($ values );
100
84
}
101
85
102
86
public function max ($ column )
@@ -105,11 +89,9 @@ public function max($column)
105
89
return parent ::max ($ column );
106
90
}
107
91
108
- $ arguments = func_get_args ();
109
92
$ cacheKey = $ this ->makeCacheKey (["* " ], null , "-max_ {$ column }" );
110
- $ method = "max " ;
111
93
112
- return $ this ->cachedValue ($ arguments , $ cacheKey, $ method );
94
+ return $ this ->cachedValue (func_get_args () , $ cacheKey );
113
95
}
114
96
115
97
public function min ($ column )
@@ -118,11 +100,9 @@ public function min($column)
118
100
return parent ::min ($ column );
119
101
}
120
102
121
- $ arguments = func_get_args ();
122
103
$ cacheKey = $ this ->makeCacheKey (["* " ], null , "-min_ {$ column }" );
123
- $ method = "min " ;
124
104
125
- return $ this ->cachedValue ($ arguments , $ cacheKey, $ method );
105
+ return $ this ->cachedValue (func_get_args () , $ cacheKey );
126
106
}
127
107
128
108
public function paginate (
@@ -135,12 +115,10 @@ public function paginate(
135
115
return parent ::paginate ($ perPage , $ columns , $ pageName , $ page );
136
116
}
137
117
138
- $ arguments = func_get_args ();
139
118
$ page = $ page ?: 1 ;
140
119
$ cacheKey = $ this ->makeCacheKey ($ columns , null , "-paginate_by_ {$ perPage }_ {$ pageName }_ {$ page }" );
141
- $ method = "paginate " ;
142
120
143
- return $ this ->cachedValue ($ arguments , $ cacheKey, $ method );
121
+ return $ this ->cachedValue (func_get_args () , $ cacheKey );
144
122
}
145
123
146
124
public function pluck ($ column , $ key = null )
@@ -150,11 +128,9 @@ public function pluck($column, $key = null)
150
128
}
151
129
152
130
$ keyDifferentiator = "-pluck_ {$ column }" . ($ key ? "_ {$ key }" : "" );
153
- $ arguments = func_get_args ();
154
131
$ cacheKey = $ this ->makeCacheKey ([$ column ], null , $ keyDifferentiator );
155
- $ method = "pluck " ;
156
132
157
- return $ this ->cachedValue ($ arguments , $ cacheKey, $ method );
133
+ return $ this ->cachedValue (func_get_args () , $ cacheKey );
158
134
}
159
135
160
136
public function sum ($ column )
@@ -163,11 +139,16 @@ public function sum($column)
163
139
return parent ::sum ($ column );
164
140
}
165
141
166
- $ arguments = func_get_args ();
167
142
$ cacheKey = $ this ->makeCacheKey (["* " ], null , "-sum_ {$ column }" );
168
- $ method = "sum " ;
169
143
170
- return $ this ->cachedValue ($ arguments , $ cacheKey , $ method );
144
+ return $ this ->cachedValue (func_get_args (), $ cacheKey );
145
+ }
146
+
147
+ public function update (array $ values )
148
+ {
149
+ $ this ->checkCooldownAndFlushAfterPersiting ($ this ->model );
150
+
151
+ return parent ::update ($ values );
171
152
}
172
153
173
154
public function value ($ column )
@@ -176,15 +157,14 @@ public function value($column)
176
157
return parent ::value ($ column );
177
158
}
178
159
179
- $ arguments = func_get_args ();
180
160
$ cacheKey = $ this ->makeCacheKey (["* " ], null , "-value_ {$ column }" );
181
- $ method = "value " ;
182
161
183
- return $ this ->cachedValue ($ arguments , $ cacheKey, $ method );
162
+ return $ this ->cachedValue (func_get_args () , $ cacheKey );
184
163
}
185
164
186
- public function cachedValue (array $ arguments , string $ cacheKey, string $ method )
165
+ public function cachedValue (array $ arguments , string $ cacheKey )
187
166
{
167
+ $ method = debug_backtrace ()[1 ]['function ' ];
188
168
$ cacheTags = $ this ->makeCacheTags ();
189
169
$ hashedCacheKey = sha1 ($ cacheKey );
190
170
$ result = $ this ->retrieveCachedValue (
0 commit comments