File tree Expand file tree Collapse file tree 1 file changed +11
-9
lines changed
src/Symfony/Component/Cache/Adapter Expand file tree Collapse file tree 1 file changed +11
-9
lines changed Original file line number Diff line number Diff line change @@ -93,22 +93,24 @@ protected function doSave(array $values, $lifetime)
93
93
$ serialized = array ();
94
94
$ failed = array ();
95
95
96
- foreach ($ values as $ id => $ v ) {
96
+ foreach ($ values as $ id => $ value ) {
97
97
try {
98
- $ serialized [$ id ] = serialize ($ v );
98
+ $ serialized [$ id ] = serialize ($ value );
99
99
} catch (\Exception $ e ) {
100
100
$ failed [] = $ id ;
101
101
}
102
102
}
103
103
104
- if (!$ this ->redis ->mSet ($ serialized )) {
105
- return false ;
106
- }
107
-
108
- if ($ lifetime >= 1 ) {
109
- foreach ($ serialized as $ id => $ v ) {
110
- $ this ->redis ->expire ($ id , $ lifetime );
104
+ if ($ lifetime > 0 ) {
105
+ $ pipe = $ this ->redis ->multi (\Redis::PIPELINE );
106
+ foreach ($ serialized as $ id => $ value ) {
107
+ $ pipe ->setEx ($ id , $ lifetime , $ value );
111
108
}
109
+ if (!$ pipe ->exec ()) {
110
+ return false ;
111
+ }
112
+ } elseif (!$ this ->redis ->mSet ($ serialized )) {
113
+ return false ;
112
114
}
113
115
114
116
return $ failed ;
You can’t perform that action at this time.
0 commit comments