@@ -294,21 +294,7 @@ public function multiSet($items, $duration = null, $dependency = null)
294
294
$ duration = $ this ->defaultDuration ;
295
295
}
296
296
297
- if ($ dependency !== null && $ this ->serializer !== false ) {
298
- $ dependency ->evaluateDependency ($ this );
299
- }
300
-
301
- $ data = [];
302
- foreach ($ items as $ key => $ value ) {
303
- if ($ this ->serializer === null ) {
304
- $ value = serialize ([$ value , $ dependency ]);
305
- } elseif ($ this ->serializer !== false ) {
306
- $ value = call_user_func ($ this ->serializer [0 ], [$ value , $ dependency ]);
307
- }
308
-
309
- $ key = $ this ->buildKey ($ key );
310
- $ data [$ key ] = $ value ;
311
- }
297
+ $ data = $ this ->prepareCacheData ($ items , $ dependency );
312
298
313
299
return $ this ->setValues ($ data , $ duration );
314
300
}
@@ -343,6 +329,21 @@ public function madd($items, $duration = 0, $dependency = null)
343
329
* @since 2.0.7
344
330
*/
345
331
public function multiAdd ($ items , $ duration = 0 , $ dependency = null )
332
+ {
333
+ $ data = $ this ->prepareCacheData ($ items , $ dependency );
334
+
335
+ return $ this ->addValues ($ data , $ duration );
336
+ }
337
+
338
+ /**
339
+ * Prepares data for caching by serializing values and evaluating dependencies.
340
+ *
341
+ * @param array $items The items to be cached.
342
+ * @param mixed $dependency The dependency to be evaluated.
343
+ *
344
+ * @return array The prepared data for caching.
345
+ */
346
+ private function prepareCacheData ($ items , $ dependency )
346
347
{
347
348
if ($ dependency !== null && $ this ->serializer !== false ) {
348
349
$ dependency ->evaluateDependency ($ this );
@@ -360,7 +361,7 @@ public function multiAdd($items, $duration = 0, $dependency = null)
360
361
$ data [$ key ] = $ value ;
361
362
}
362
363
363
- return $ this -> addValues ( $ data, $ duration ) ;
364
+ return $ data ;
364
365
}
365
366
366
367
/**
0 commit comments