File tree Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -144,6 +144,13 @@ public function sum($column)
144144 return $ this ->cachedValue (func_get_args (), $ cacheKey );
145145 }
146146
147+ public function update (array $ values )
148+ {
149+ $ this ->checkCooldownAndFlushAfterPersiting ($ this ->model );
150+
151+ return parent ::update ($ values );
152+ }
153+
147154 public function value ($ column )
148155 {
149156 if (! $ this ->isCachable ()) {
Original file line number Diff line number Diff line change @@ -909,4 +909,24 @@ public function testInsertInvalidatesCache()
909909 $ this ->assertCount (11 , $ authorsAfterInsert );
910910 $ this ->assertCount (11 , $ uncachedAuthors );
911911 }
912+
913+ public function testUpdateInvalidatesCache ()
914+ {
915+ $ originalAuthor = (new Author )
916+ ->first ();
917+ $ author = (new Author )
918+ ->first ();
919+
920+ $ author ->update ([
921+ "name " => "Updated Name " ,
922+ ]);
923+ $ authorAfterUpdate = (new Author )
924+ ->find ($ author ->id );
925+ $ uncachedAuthor = (new UncachedAuthor )
926+ ->find ($ author ->id );
927+
928+ $ this ->assertNotEquals ($ originalAuthor ->name , $ authorAfterUpdate ->name );
929+ $ this ->assertEquals ("Updated Name " , $ authorAfterUpdate ->name );
930+ $ this ->assertEquals ($ authorAfterUpdate ->name , $ uncachedAuthor ->name );
931+ }
912932}
You can’t perform that action at this time.
0 commit comments