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 = ["*"])
60
60
return parent ::find ($ id , $ columns );
61
61
}
62
62
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 }" );
66
69
67
70
return $ this ->cachedValue (func_get_args (), $ cacheKey );
68
71
}
Original file line number Diff line number Diff line change @@ -33,6 +33,24 @@ public function testFindModelResultsCreatesCache()
33
33
$ this ->assertEmpty ($ liveResults ->diffKeys ($ cachedResults ));
34
34
}
35
35
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
+
36
54
public function testSubsequentFindsReturnDifferentModels ()
37
55
{
38
56
$ author1 = (new Author )->find (1 );
You can’t perform that action at this time.
0 commit comments