@@ -51,9 +51,9 @@ class MyAwesomeClass
51
51
$searchCriteria,
52
52
$productRepository,
53
53
$callback,
54
- $pageSize = 100 ,
54
+ $pageSize = 1000 ,
55
55
$maxChildrenProcess = 10,
56
- $isParallelize = true
56
+ $isIdempotent = true
57
57
);
58
58
}
59
59
```
@@ -86,9 +86,9 @@ class MyAwesomeClass
86
86
$searchCriteria,
87
87
$productRepository,
88
88
$callback,
89
- $pageSize = 100 ,
89
+ $pageSize = 1000 ,
90
90
$maxChildrenProcess = 10,
91
- $isParallelize = true
91
+ $isIdempotent = true
92
92
);
93
93
}
94
94
```
@@ -119,8 +119,7 @@ class MyAwesomeClass
119
119
$array,
120
120
$callback,
121
121
$pageSize = 2,
122
- $maxChildrenProcess = 2,
123
- $isParallelize = true
122
+ $maxChildrenProcess = 2
124
123
);
125
124
}
126
125
```
@@ -166,16 +165,18 @@ function specified by the user on each item of that page.
166
165
167
166
- ` $maxChildrenProcess ` : This parameter is used to set the maximum number of child
168
167
processes that can be run simultaneously. This is used to control the number of threads
169
- that will be used by the multi-threading process.
170
-
171
- - ` $isParallelize ` : This parameter is used to set whether the multi-threading process should run
172
- in parallel or sequentially. If set to true, the process will run in parallel,
173
- if set to false, the process will run sequentially. Running task sequentially may be useful when
174
- you want to keep the sort order of your items.
175
-
176
- - ` $isFallBackEnabled ` : This parameter is set to false by default and can be used for ` ForkedSearchResultProcessor `
177
- or ` ForkedCollectionProcessor ` it can be useful only if your initial query has a flag
178
- that will be processed in your callback method.
168
+ that will be used by the multi-threading process. If set to 1, by definition you will have no parallelization,
169
+ the parent process will wait the child process to finish before creating another one.
170
+
171
+ - ` $isIdempotent ` : This parameter is a flag set to ` true ` by default and can be used for ` ForkedSearchResultProcessor `
172
+ or ` ForkedCollectionProcessor ` when your ` $maxChildrenProcess ` is greater than one.
173
+ While fetching data from database with ` ForkedSearchResult ` and ` ForkedCollectionProcessor ` you may change values
174
+ queried: by modifying items on columns queried you will change the nature of the initial collection query and at the end,
175
+ the OFFSET limit in the query will be invalid because the native pagination system expect the pagination to be
176
+ processed by only one process. To avoid that, set ` $isIdempotent ` to ` false ` .<br >
177
+ E.G.: In your collection query, you request all products ` disabled ` , in your callback method you ` enable ` and save
178
+ them in database, then in this particular case you are modifying the column that you request in your collection,
179
+ your query is not idempotent.
179
180
180
181
### Memory Limit
181
182
This module allows to bypass the limitation of the memory limit, because the memory
@@ -188,28 +189,6 @@ system and adjust the parameters accordingly.
188
189
### Limitations
189
190
This module uses ` pcntl_fork() ` function which is not available on Windows.
190
191
191
- There is limitation for Multi-threading pagination on ` ForkedSearchResultProcessor ` and ` ForkedCollectionProcessor ` :<br >
192
- Multi-threading pagination works only if your initial query has a flag that will be excluded
193
- from results on each pagination iteration.
194
-
195
- For example:<br >
196
- You select all orders without a ` gift_cards ` value in your query, if you set a ` gift_cards ` value on your callback
197
- method and save it in database, then multi-threading and fallback system will work.
198
- Otherwise, children will go for the same items because your query doesn't flag a specific column modified
199
- by your callback function.<br >
200
- <b >So currently you need a flag to be sure to not proceed the same items</b >.
201
-
202
- Workaround:<br >
203
- You can create your own flag by using a column like modified_at in your collection/searchCriteria query
204
- to request items with a modified_at value lower than the current timestamp, then you just have to update
205
- the modified_at column in your callback method and set the current timestamp.
206
- This way your query will fetch fresh items on each iteration.
207
-
208
- I will provide support to handle this soon, sorry for the inconvenient.
209
- Until then if you want to process data, I recommend usage of single thread solution,
210
- or the ` ForkedArrayProcessor ` which is not impacted by pagination system.
211
-
212
-
213
192
### Conclusion
214
193
This module provides a useful tool for running commands or processing collections
215
194
and search criteria in a multi-threaded way, making it a great solution for improving
0 commit comments