@@ -16,11 +16,9 @@ public function avg($column)
1616 return parent ::avg ($ column );
1717 }
1818
19- $ arguments = func_get_args ();
2019 $ cacheKey = $ this ->makeCacheKey (["* " ], null , "-avg_ {$ column }" );
21- $ method = "avg " ;
2220
23- return $ this ->cachedValue ($ arguments , $ cacheKey, $ method );
21+ return $ this ->cachedValue (func_get_args () , $ cacheKey );
2422 }
2523
2624 public function count ($ columns = ["* " ])
@@ -29,24 +27,9 @@ public function count($columns = ["*"])
2927 return parent ::count ($ columns );
3028 }
3129
32- $ arguments = func_get_args ();
33- $ cacheKey = $ this ->makeCacheKey (["* " ], null , "-count " );
34- $ method = "count " ;
30+ $ cacheKey = $ this ->makeCacheKey ($ columns , null , "-count " );
3531
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 );
5033 }
5134
5235 public function delete ()
@@ -66,11 +49,9 @@ public function find($id, $columns = ["*"])
6649 return parent ::find ($ id , $ columns );
6750 }
6851
69- $ arguments = func_get_args ();
70- $ cacheKey = $ this ->makeCacheKey (["* " ], null , "-find_ {$ id }" );
71- $ method = "find " ;
52+ $ cacheKey = $ this ->makeCacheKey ($ columns , null , "-find_ {$ id }" );
7253
73- return $ this ->cachedValue ($ arguments , $ cacheKey, $ method );
54+ return $ this ->cachedValue (func_get_args () , $ cacheKey );
7455 }
7556
7657 public function first ($ columns = ["* " ])
@@ -79,11 +60,9 @@ public function first($columns = ["*"])
7960 return parent ::first ($ columns );
8061 }
8162
82- $ arguments = func_get_args ();
8363 $ cacheKey = $ this ->makeCacheKey ($ columns );
84- $ method = "first " ;
8564
86- return $ this ->cachedValue ($ arguments , $ cacheKey, $ method );
65+ return $ this ->cachedValue (func_get_args () , $ cacheKey );
8766 }
8867
8968 public function get ($ columns = ["* " ])
@@ -92,11 +71,16 @@ public function get($columns = ["*"])
9271 return parent ::get ($ columns );
9372 }
9473
95- $ arguments = func_get_args ();
9674 $ cacheKey = $ this ->makeCacheKey ($ columns );
97- $ method = "get " ;
9875
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 );
10084 }
10185
10286 public function max ($ column )
@@ -105,11 +89,9 @@ public function max($column)
10589 return parent ::max ($ column );
10690 }
10791
108- $ arguments = func_get_args ();
10992 $ cacheKey = $ this ->makeCacheKey (["* " ], null , "-max_ {$ column }" );
110- $ method = "max " ;
11193
112- return $ this ->cachedValue ($ arguments , $ cacheKey, $ method );
94+ return $ this ->cachedValue (func_get_args () , $ cacheKey );
11395 }
11496
11597 public function min ($ column )
@@ -118,11 +100,9 @@ public function min($column)
118100 return parent ::min ($ column );
119101 }
120102
121- $ arguments = func_get_args ();
122103 $ cacheKey = $ this ->makeCacheKey (["* " ], null , "-min_ {$ column }" );
123- $ method = "min " ;
124104
125- return $ this ->cachedValue ($ arguments , $ cacheKey, $ method );
105+ return $ this ->cachedValue (func_get_args () , $ cacheKey );
126106 }
127107
128108 public function paginate (
@@ -135,12 +115,10 @@ public function paginate(
135115 return parent ::paginate ($ perPage , $ columns , $ pageName , $ page );
136116 }
137117
138- $ arguments = func_get_args ();
139118 $ page = $ page ?: 1 ;
140119 $ cacheKey = $ this ->makeCacheKey ($ columns , null , "-paginate_by_ {$ perPage }_ {$ pageName }_ {$ page }" );
141- $ method = "paginate " ;
142120
143- return $ this ->cachedValue ($ arguments , $ cacheKey, $ method );
121+ return $ this ->cachedValue (func_get_args () , $ cacheKey );
144122 }
145123
146124 public function pluck ($ column , $ key = null )
@@ -150,11 +128,9 @@ public function pluck($column, $key = null)
150128 }
151129
152130 $ keyDifferentiator = "-pluck_ {$ column }" . ($ key ? "_ {$ key }" : "" );
153- $ arguments = func_get_args ();
154131 $ cacheKey = $ this ->makeCacheKey ([$ column ], null , $ keyDifferentiator );
155- $ method = "pluck " ;
156132
157- return $ this ->cachedValue ($ arguments , $ cacheKey, $ method );
133+ return $ this ->cachedValue (func_get_args () , $ cacheKey );
158134 }
159135
160136 public function sum ($ column )
@@ -163,11 +139,16 @@ public function sum($column)
163139 return parent ::sum ($ column );
164140 }
165141
166- $ arguments = func_get_args ();
167142 $ cacheKey = $ this ->makeCacheKey (["* " ], null , "-sum_ {$ column }" );
168- $ method = "sum " ;
169143
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 );
171152 }
172153
173154 public function value ($ column )
@@ -176,15 +157,14 @@ public function value($column)
176157 return parent ::value ($ column );
177158 }
178159
179- $ arguments = func_get_args ();
180160 $ cacheKey = $ this ->makeCacheKey (["* " ], null , "-value_ {$ column }" );
181- $ method = "value " ;
182161
183- return $ this ->cachedValue ($ arguments , $ cacheKey, $ method );
162+ return $ this ->cachedValue (func_get_args () , $ cacheKey );
184163 }
185164
186- public function cachedValue (array $ arguments , string $ cacheKey, string $ method )
165+ public function cachedValue (array $ arguments , string $ cacheKey )
187166 {
167+ $ method = debug_backtrace ()[1 ]['function ' ];
188168 $ cacheTags = $ this ->makeCacheTags ();
189169 $ hashedCacheKey = sha1 ($ cacheKey );
190170 $ result = $ this ->retrieveCachedValue (
0 commit comments