File tree Expand file tree Collapse file tree 2 files changed +18
-6
lines changed Expand file tree Collapse file tree 2 files changed +18
-6
lines changed Original file line number Diff line number Diff line change @@ -68,12 +68,9 @@ public function many(array $keys)
6868
6969 if (count ($ missing ) > 0 ) {
7070 $ retrieved = tap ($ this ->repository ->many ($ missing ), function ($ values ) {
71- $ this ->cache = [
72- ...$ this ->cache ,
73- ...collect ($ values )->mapWithKeys (fn ($ value , $ key ) => [
74- $ this ->prefix ($ key ) => $ value ,
75- ]),
76- ];
71+ foreach ($ values as $ key => $ value ) {
72+ $ this ->cache [$ this ->prefix ($ key )] = $ value ;
73+ }
7774 });
7875 }
7976
Original file line number Diff line number Diff line change @@ -121,6 +121,21 @@ public function test_it_uses_correct_keys_for_getMultiple()
121121 $ this ->assertSame ($ cacheValue , $ memoValue );
122122 }
123123
124+ public function test_it_uses_correct_keys_for_getMultiple_with_empty_prefix ()
125+ {
126+ Cache::setPrefix (null );
127+
128+ $ data = [
129+ '1 ' => 'one ' ,
130+ 0 => 'zero ' ,
131+ ];
132+ Cache::putMany ($ data );
133+
134+ $ this ->assertSame ($ data , Cache::memo ()->many (array_keys ($ data )));
135+ // ensure correct on the second memoized retrieval
136+ $ this ->assertSame ($ data , Cache::memo ()->many (array_keys ($ data )));
137+ }
138+
124139 public function test_null_values_are_memoized_when_retrieving_multiple_values ()
125140 {
126141 $ live = Cache::getMultiple (['name.0 ' , 'name.1 ' ]);
You can’t perform that action at this time.
0 commit comments