Modules: reformat RM_Scan() top comment a bit.

This commit is contained in:
antirez 2020-02-28 18:09:46 +01:00
parent 8a3e9a6d44
commit c8ae90fef6

View File

@ -6526,24 +6526,32 @@ void RM_ScanCursorDestroy(RedisModuleScanCursor *cursor) {
zfree(cursor); zfree(cursor);
} }
/* Scan api that allows a module to scan all the keys and value in the selected db. /* Scan API that allows a module to scan all the keys and value in
* the selected db.
* *
* Callback for scan implementation. * Callback for scan implementation.
* void scan_callback(RedisModuleCtx *ctx, RedisModuleString *keyname, RedisModuleKey *key, void *privdata); * void scan_callback(RedisModuleCtx *ctx, RedisModuleString *keyname,
* - ctx - the redis module context provided to for the scan. * RedisModuleKey *key, void *privdata);
* - keyname - owned by the caller and need to be retained if used after this function. * ctx - the redis module context provided to for the scan.
* - key - holds info on the key and value, it is provided as best effort, in some cases it might * keyname - owned by the caller and need to be retained if used after this
* be NULL, in which case the user should (can) use RedisModule_OpenKey (and CloseKey too). * function.
* when it is provided, it is owned by the caller and will be free when the callback returns. *
* - privdata - the user data provided to RedisModule_Scan. * key - holds info on the key and value, it is provided as best effort, in
* some cases it might be NULL, in which case the user should (can) use
* RedisModule_OpenKey (and CloseKey too).
* when it is provided, it is owned by the caller and will be free when the
* callback returns.
*
* privdata - the user data provided to RedisModule_Scan.
* *
* The way it should be used: * The way it should be used:
* RedisModuleCursor *c = RedisModule_ScanCursorCreate(); * RedisModuleCursor *c = RedisModule_ScanCursorCreate();
* while(RedisModule_Scan(ctx, c, callback, privateData)); * while(RedisModule_Scan(ctx, c, callback, privateData));
* RedisModule_ScanCursorDestroy(c); * RedisModule_ScanCursorDestroy(c);
* *
* It is also possible to use this API from another thread while the lock is acquired durring * It is also possible to use this API from another thread while the lock
* the actuall call to RM_Scan: * is acquired durring the actuall call to RM_Scan:
*
* RedisModuleCursor *c = RedisModule_ScanCursorCreate(); * RedisModuleCursor *c = RedisModule_ScanCursorCreate();
* RedisModule_ThreadSafeContextLock(ctx); * RedisModule_ThreadSafeContextLock(ctx);
* while(RedisModule_Scan(ctx, c, callback, privateData)){ * while(RedisModule_Scan(ctx, c, callback, privateData)){
@ -6553,8 +6561,9 @@ void RM_ScanCursorDestroy(RedisModuleScanCursor *cursor) {
* } * }
* RedisModule_ScanCursorDestroy(c); * RedisModule_ScanCursorDestroy(c);
* *
* The function will return 1 if there are more elements to scan and 0 otherwise, * The function will return 1 if there are more elements to scan and
* possibly setting errno if the call failed. * 0 otherwise, possibly setting errno if the call failed.
*
* It is also possible to restart and existing cursor using RM_CursorRestart. * It is also possible to restart and existing cursor using RM_CursorRestart.
* *
* IMPORTANT: This API is very similar to the Redis SCAN command from the * IMPORTANT: This API is very similar to the Redis SCAN command from the