File tree Expand file tree Collapse file tree 2 files changed +24
-3
lines changed
tests/Integration/CachedBuilder Expand file tree Collapse file tree 2 files changed +24
-3
lines changed Original file line number Diff line number Diff line change @@ -60,9 +60,12 @@ public function find($id, $columns = ["*"])
6060 return parent ::find ($ id , $ columns );
6161 }
6262
63- $ idKey = collect ($ id )->implode ('- ' );
64- $ preStr = is_array ($ id ) ? 'find-list ' : 'find ' ;
65- $ cacheKey = $ this ->makeCacheKey ($ columns , null , "- " . $ preStr . "_ {$ idKey }" );
63+ $ idKey = collect ($ id )
64+ ->implode ('_ ' );
65+ $ preStr = is_array ($ id )
66+ ? 'find_list '
67+ : 'find ' ;
68+ $ cacheKey = $ this ->makeCacheKey ($ columns , null , "- {$ preStr }_ {$ idKey }" );
6669
6770 return $ this ->cachedValue (func_get_args (), $ cacheKey );
6871 }
Original file line number Diff line number Diff line change @@ -33,6 +33,24 @@ public function testFindModelResultsCreatesCache()
3333 $ this ->assertEmpty ($ liveResults ->diffKeys ($ cachedResults ));
3434 }
3535
36+ public function testFindMultipleModelResultsCreatesCache ()
37+ {
38+ $ authors = (new Author )->find ([1 , 2 , 3 ]);
39+ $ key = sha1 ('genealabs:laravel-model-caching:testing::memory::authors:genealabslaravelmodelcachingtestsfixturesauthor-find_list_1_2_3 ' );
40+ $ tags = [
41+ 'genealabs:laravel-model-caching:testing::memory::genealabslaravelmodelcachingtestsfixturesauthor ' ,
42+ ];
43+
44+ $ cachedResults = $ this
45+ ->cache ()
46+ ->tags ($ tags )
47+ ->get ($ key )["value " ];
48+ $ liveResults = (new UncachedAuthor )->find ([1 , 2 , 3 ]);
49+
50+ $ this ->assertEquals ($ authors ->pluck ("id " ), $ cachedResults ->pluck ("id " ));
51+ $ this ->assertEquals ($ liveResults ->pluck ("id " ), $ cachedResults ->pluck ("id " ));
52+ }
53+
3654 public function testSubsequentFindsReturnDifferentModels ()
3755 {
3856 $ author1 = (new Author )->find (1 );
You can’t perform that action at this time.
0 commit comments