Perform a late defrag of a module datatype key. * * Returns a zero value (and initializes the cursor) if no more needs to be done, * or a non-zero value otherwise. */
| 9359 | * or a non-zero value otherwise. |
| 9360 | */ |
| 9361 | int moduleLateDefrag(robj *key, robj *value, unsigned long *cursor, long long endtime, long long *defragged) { |
| 9362 | moduleValue *mv = (moduleValue*)ptrFromObj(value); |
| 9363 | moduleType *mt = mv->type; |
| 9364 | |
| 9365 | RedisModuleDefragCtx defrag_ctx = { 0, endtime, cursor }; |
| 9366 | |
| 9367 | /* Invoke callback. Note that the callback may be missing if the key has been |
| 9368 | * replaced with a different type since our last visit. |
| 9369 | */ |
| 9370 | int ret = 0; |
| 9371 | if (mt->defrag) |
| 9372 | ret = mt->defrag(&defrag_ctx, key, &mv->value); |
| 9373 | |
| 9374 | *defragged += defrag_ctx.defragged; |
| 9375 | if (!ret) { |
| 9376 | *cursor = 0; /* No more work to do */ |
| 9377 | return 0; |
| 9378 | } |
| 9379 | |
| 9380 | return 1; |
| 9381 | } |
| 9382 | |
| 9383 | /* Attempt to defrag a module data type value. Depending on complexity, |
| 9384 | * the operation may happen immediately or be scheduled for later. |
no test coverage detected