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. */
| 9157 | * or a non-zero value otherwise. |
| 9158 | */ |
| 9159 | int moduleLateDefrag(robj *key, robj *value, unsigned long *cursor, long long endtime, long long *defragged) { |
| 9160 | moduleValue *mv = value->ptr; |
| 9161 | moduleType *mt = mv->type; |
| 9162 | |
| 9163 | RedisModuleDefragCtx defrag_ctx = { 0, endtime, cursor }; |
| 9164 | |
| 9165 | /* Invoke callback. Note that the callback may be missing if the key has been |
| 9166 | * replaced with a different type since our last visit. |
| 9167 | */ |
| 9168 | int ret = 0; |
| 9169 | if (mt->defrag) |
| 9170 | ret = mt->defrag(&defrag_ctx, key, &mv->value); |
| 9171 | |
| 9172 | *defragged += defrag_ctx.defragged; |
| 9173 | if (!ret) { |
| 9174 | *cursor = 0; /* No more work to do */ |
| 9175 | return 0; |
| 9176 | } |
| 9177 | |
| 9178 | return 1; |
| 9179 | } |
| 9180 | |
| 9181 | /* Attempt to defrag a module data type value. Depending on complexity, |
| 9182 | * the operation may happen immediately or be scheduled for later. |