"Fossies" - the Fresh Open Source Software Archive

Member "redis-6.0.8/src/redismodule.h" (10 Sep 2020, 57085 Bytes) of package /linux/misc/redis-6.0.8.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "redismodule.h" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 6.0.7_vs_6.0.8.

    1 #ifndef REDISMODULE_H
    2 #define REDISMODULE_H
    3 
    4 #include <sys/types.h>
    5 #include <stdint.h>
    6 #include <stdio.h>
    7 
    8 /* ---------------- Defines common between core and modules --------------- */
    9 
   10 /* Error status return values. */
   11 #define REDISMODULE_OK 0
   12 #define REDISMODULE_ERR 1
   13 
   14 /* API versions. */
   15 #define REDISMODULE_APIVER_1 1
   16 
   17 /* API flags and constants */
   18 #define REDISMODULE_READ (1<<0)
   19 #define REDISMODULE_WRITE (1<<1)
   20 
   21 /* RedisModule_OpenKey extra flags for the 'mode' argument.
   22  * Avoid touching the LRU/LFU of the key when opened. */
   23 #define REDISMODULE_OPEN_KEY_NOTOUCH (1<<16)
   24 
   25 #define REDISMODULE_LIST_HEAD 0
   26 #define REDISMODULE_LIST_TAIL 1
   27 
   28 /* Key types. */
   29 #define REDISMODULE_KEYTYPE_EMPTY 0
   30 #define REDISMODULE_KEYTYPE_STRING 1
   31 #define REDISMODULE_KEYTYPE_LIST 2
   32 #define REDISMODULE_KEYTYPE_HASH 3
   33 #define REDISMODULE_KEYTYPE_SET 4
   34 #define REDISMODULE_KEYTYPE_ZSET 5
   35 #define REDISMODULE_KEYTYPE_MODULE 6
   36 #define REDISMODULE_KEYTYPE_STREAM 7
   37 
   38 /* Reply types. */
   39 #define REDISMODULE_REPLY_UNKNOWN -1
   40 #define REDISMODULE_REPLY_STRING 0
   41 #define REDISMODULE_REPLY_ERROR 1
   42 #define REDISMODULE_REPLY_INTEGER 2
   43 #define REDISMODULE_REPLY_ARRAY 3
   44 #define REDISMODULE_REPLY_NULL 4
   45 
   46 /* Postponed array length. */
   47 #define REDISMODULE_POSTPONED_ARRAY_LEN -1
   48 
   49 /* Expire */
   50 #define REDISMODULE_NO_EXPIRE -1
   51 
   52 /* Sorted set API flags. */
   53 #define REDISMODULE_ZADD_XX      (1<<0)
   54 #define REDISMODULE_ZADD_NX      (1<<1)
   55 #define REDISMODULE_ZADD_ADDED   (1<<2)
   56 #define REDISMODULE_ZADD_UPDATED (1<<3)
   57 #define REDISMODULE_ZADD_NOP     (1<<4)
   58 
   59 /* Hash API flags. */
   60 #define REDISMODULE_HASH_NONE       0
   61 #define REDISMODULE_HASH_NX         (1<<0)
   62 #define REDISMODULE_HASH_XX         (1<<1)
   63 #define REDISMODULE_HASH_CFIELDS    (1<<2)
   64 #define REDISMODULE_HASH_EXISTS     (1<<3)
   65 
   66 /* Context Flags: Info about the current context returned by
   67  * RM_GetContextFlags(). */
   68 
   69 /* The command is running in the context of a Lua script */
   70 #define REDISMODULE_CTX_FLAGS_LUA (1<<0)
   71 /* The command is running inside a Redis transaction */
   72 #define REDISMODULE_CTX_FLAGS_MULTI (1<<1)
   73 /* The instance is a master */
   74 #define REDISMODULE_CTX_FLAGS_MASTER (1<<2)
   75 /* The instance is a slave */
   76 #define REDISMODULE_CTX_FLAGS_SLAVE (1<<3)
   77 /* The instance is read-only (usually meaning it's a slave as well) */
   78 #define REDISMODULE_CTX_FLAGS_READONLY (1<<4)
   79 /* The instance is running in cluster mode */
   80 #define REDISMODULE_CTX_FLAGS_CLUSTER (1<<5)
   81 /* The instance has AOF enabled */
   82 #define REDISMODULE_CTX_FLAGS_AOF (1<<6)
   83 /* The instance has RDB enabled */
   84 #define REDISMODULE_CTX_FLAGS_RDB (1<<7)
   85 /* The instance has Maxmemory set */
   86 #define REDISMODULE_CTX_FLAGS_MAXMEMORY (1<<8)
   87 /* Maxmemory is set and has an eviction policy that may delete keys */
   88 #define REDISMODULE_CTX_FLAGS_EVICT (1<<9)
   89 /* Redis is out of memory according to the maxmemory flag. */
   90 #define REDISMODULE_CTX_FLAGS_OOM (1<<10)
   91 /* Less than 25% of memory available according to maxmemory. */
   92 #define REDISMODULE_CTX_FLAGS_OOM_WARNING (1<<11)
   93 /* The command was sent over the replication link. */
   94 #define REDISMODULE_CTX_FLAGS_REPLICATED (1<<12)
   95 /* Redis is currently loading either from AOF or RDB. */
   96 #define REDISMODULE_CTX_FLAGS_LOADING (1<<13)
   97 /* The replica has no link with its master, note that
   98  * there is the inverse flag as well:
   99  *
  100  *  REDISMODULE_CTX_FLAGS_REPLICA_IS_ONLINE
  101  *
  102  * The two flags are exclusive, one or the other can be set. */
  103 #define REDISMODULE_CTX_FLAGS_REPLICA_IS_STALE (1<<14)
  104 /* The replica is trying to connect with the master.
  105  * (REPL_STATE_CONNECT and REPL_STATE_CONNECTING states) */
  106 #define REDISMODULE_CTX_FLAGS_REPLICA_IS_CONNECTING (1<<15)
  107 /* THe replica is receiving an RDB file from its master. */
  108 #define REDISMODULE_CTX_FLAGS_REPLICA_IS_TRANSFERRING (1<<16)
  109 /* The replica is online, receiving updates from its master. */
  110 #define REDISMODULE_CTX_FLAGS_REPLICA_IS_ONLINE (1<<17)
  111 /* There is currently some background process active. */
  112 #define REDISMODULE_CTX_FLAGS_ACTIVE_CHILD (1<<18)
  113 /* The next EXEC will fail due to dirty CAS (touched keys). */
  114 #define REDISMODULE_CTX_FLAGS_MULTI_DIRTY (1<<19)
  115 
  116 /* Keyspace changes notification classes. Every class is associated with a
  117  * character for configuration purposes.
  118  * NOTE: These have to be in sync with NOTIFY_* in server.h */
  119 #define REDISMODULE_NOTIFY_KEYSPACE (1<<0)    /* K */
  120 #define REDISMODULE_NOTIFY_KEYEVENT (1<<1)    /* E */
  121 #define REDISMODULE_NOTIFY_GENERIC (1<<2)     /* g */
  122 #define REDISMODULE_NOTIFY_STRING (1<<3)      /* $ */
  123 #define REDISMODULE_NOTIFY_LIST (1<<4)        /* l */
  124 #define REDISMODULE_NOTIFY_SET (1<<5)         /* s */
  125 #define REDISMODULE_NOTIFY_HASH (1<<6)        /* h */
  126 #define REDISMODULE_NOTIFY_ZSET (1<<7)        /* z */
  127 #define REDISMODULE_NOTIFY_EXPIRED (1<<8)     /* x */
  128 #define REDISMODULE_NOTIFY_EVICTED (1<<9)     /* e */
  129 #define REDISMODULE_NOTIFY_STREAM (1<<10)     /* t */
  130 #define REDISMODULE_NOTIFY_KEY_MISS (1<<11)   /* m (Note: This one is excluded from REDISMODULE_NOTIFY_ALL on purpose) */
  131 #define REDISMODULE_NOTIFY_LOADED (1<<12)     /* module only key space notification, indicate a key loaded from rdb */
  132 #define REDISMODULE_NOTIFY_ALL (REDISMODULE_NOTIFY_GENERIC | REDISMODULE_NOTIFY_STRING | REDISMODULE_NOTIFY_LIST | REDISMODULE_NOTIFY_SET | REDISMODULE_NOTIFY_HASH | REDISMODULE_NOTIFY_ZSET | REDISMODULE_NOTIFY_EXPIRED | REDISMODULE_NOTIFY_EVICTED | REDISMODULE_NOTIFY_STREAM)      /* A */
  133 
  134 /* A special pointer that we can use between the core and the module to signal
  135  * field deletion, and that is impossible to be a valid pointer. */
  136 #define REDISMODULE_HASH_DELETE ((RedisModuleString*)(long)1)
  137 
  138 /* Error messages. */
  139 #define REDISMODULE_ERRORMSG_WRONGTYPE "WRONGTYPE Operation against a key holding the wrong kind of value"
  140 
  141 #define REDISMODULE_POSITIVE_INFINITE (1.0/0.0)
  142 #define REDISMODULE_NEGATIVE_INFINITE (-1.0/0.0)
  143 
  144 /* Cluster API defines. */
  145 #define REDISMODULE_NODE_ID_LEN 40
  146 #define REDISMODULE_NODE_MYSELF     (1<<0)
  147 #define REDISMODULE_NODE_MASTER     (1<<1)
  148 #define REDISMODULE_NODE_SLAVE      (1<<2)
  149 #define REDISMODULE_NODE_PFAIL      (1<<3)
  150 #define REDISMODULE_NODE_FAIL       (1<<4)
  151 #define REDISMODULE_NODE_NOFAILOVER (1<<5)
  152 
  153 #define REDISMODULE_CLUSTER_FLAG_NONE 0
  154 #define REDISMODULE_CLUSTER_FLAG_NO_FAILOVER (1<<1)
  155 #define REDISMODULE_CLUSTER_FLAG_NO_REDIRECTION (1<<2)
  156 
  157 #define REDISMODULE_NOT_USED(V) ((void) V)
  158 
  159 /* Bit flags for aux_save_triggers and the aux_load and aux_save callbacks */
  160 #define REDISMODULE_AUX_BEFORE_RDB (1<<0)
  161 #define REDISMODULE_AUX_AFTER_RDB (1<<1)
  162 
  163 /* This type represents a timer handle, and is returned when a timer is
  164  * registered and used in order to invalidate a timer. It's just a 64 bit
  165  * number, because this is how each timer is represented inside the radix tree
  166  * of timers that are going to expire, sorted by expire time. */
  167 typedef uint64_t RedisModuleTimerID;
  168 
  169 /* CommandFilter Flags */
  170 
  171 /* Do filter RedisModule_Call() commands initiated by module itself. */
  172 #define REDISMODULE_CMDFILTER_NOSELF    (1<<0)
  173 
  174 /* Declare that the module can handle errors with RedisModule_SetModuleOptions. */
  175 #define REDISMODULE_OPTIONS_HANDLE_IO_ERRORS    (1<<0)
  176 /* When set, Redis will not call RedisModule_SignalModifiedKey(), implicitly in
  177  * RedisModule_CloseKey, and the module needs to do that when manually when keys
  178  * are modified from the user's sperspective, to invalidate WATCH. */
  179 #define REDISMODULE_OPTION_NO_IMPLICIT_SIGNAL_MODIFIED (1<<1)
  180 
  181 /* Server events definitions. */
  182 #define REDISMODULE_EVENT_REPLICATION_ROLE_CHANGED 0
  183 #define REDISMODULE_EVENT_PERSISTENCE 1
  184 #define REDISMODULE_EVENT_FLUSHDB 2
  185 #define REDISMODULE_EVENT_LOADING 3
  186 #define REDISMODULE_EVENT_CLIENT_CHANGE 4
  187 #define REDISMODULE_EVENT_SHUTDOWN 5
  188 #define REDISMODULE_EVENT_REPLICA_CHANGE 6
  189 #define REDISMODULE_EVENT_MASTER_LINK_CHANGE 7
  190 #define REDISMODULE_EVENT_CRON_LOOP 8
  191 #define REDISMODULE_EVENT_MODULE_CHANGE 9
  192 #define REDISMODULE_EVENT_LOADING_PROGRESS 10
  193 
  194 typedef struct RedisModuleEvent {
  195     uint64_t id;        /* REDISMODULE_EVENT_... defines. */
  196     uint64_t dataver;   /* Version of the structure we pass as 'data'. */
  197 } RedisModuleEvent;
  198 
  199 struct RedisModuleCtx;
  200 typedef void (*RedisModuleEventCallback)(struct RedisModuleCtx *ctx, RedisModuleEvent eid, uint64_t subevent, void *data);
  201 
  202 static const RedisModuleEvent
  203     RedisModuleEvent_ReplicationRoleChanged = {
  204         REDISMODULE_EVENT_REPLICATION_ROLE_CHANGED,
  205         1
  206     },
  207     RedisModuleEvent_Persistence = {
  208         REDISMODULE_EVENT_PERSISTENCE,
  209         1
  210     },
  211     RedisModuleEvent_FlushDB = {
  212         REDISMODULE_EVENT_FLUSHDB,
  213         1
  214     },
  215     RedisModuleEvent_Loading = {
  216         REDISMODULE_EVENT_LOADING,
  217         1
  218     },
  219     RedisModuleEvent_ClientChange = {
  220         REDISMODULE_EVENT_CLIENT_CHANGE,
  221         1
  222     },
  223     RedisModuleEvent_Shutdown = {
  224         REDISMODULE_EVENT_SHUTDOWN,
  225         1
  226     },
  227     RedisModuleEvent_ReplicaChange = {
  228         REDISMODULE_EVENT_REPLICA_CHANGE,
  229         1
  230     },
  231     RedisModuleEvent_CronLoop = {
  232         REDISMODULE_EVENT_CRON_LOOP,
  233         1
  234     },
  235     RedisModuleEvent_MasterLinkChange = {
  236         REDISMODULE_EVENT_MASTER_LINK_CHANGE,
  237         1
  238     },
  239     RedisModuleEvent_ModuleChange = {
  240         REDISMODULE_EVENT_MODULE_CHANGE,
  241         1
  242     },
  243     RedisModuleEvent_LoadingProgress = {
  244         REDISMODULE_EVENT_LOADING_PROGRESS,
  245         1
  246     };
  247 
  248 /* Those are values that are used for the 'subevent' callback argument. */
  249 #define REDISMODULE_SUBEVENT_PERSISTENCE_RDB_START 0
  250 #define REDISMODULE_SUBEVENT_PERSISTENCE_AOF_START 1
  251 #define REDISMODULE_SUBEVENT_PERSISTENCE_SYNC_RDB_START 2
  252 #define REDISMODULE_SUBEVENT_PERSISTENCE_ENDED 3
  253 #define REDISMODULE_SUBEVENT_PERSISTENCE_FAILED 4
  254 
  255 #define REDISMODULE_SUBEVENT_LOADING_RDB_START 0
  256 #define REDISMODULE_SUBEVENT_LOADING_AOF_START 1
  257 #define REDISMODULE_SUBEVENT_LOADING_REPL_START 2
  258 #define REDISMODULE_SUBEVENT_LOADING_ENDED 3
  259 #define REDISMODULE_SUBEVENT_LOADING_FAILED 4
  260 
  261 #define REDISMODULE_SUBEVENT_CLIENT_CHANGE_CONNECTED 0
  262 #define REDISMODULE_SUBEVENT_CLIENT_CHANGE_DISCONNECTED 1
  263 
  264 #define REDISMODULE_SUBEVENT_MASTER_LINK_UP 0
  265 #define REDISMODULE_SUBEVENT_MASTER_LINK_DOWN 1
  266 
  267 #define REDISMODULE_SUBEVENT_REPLICA_CHANGE_ONLINE 0
  268 #define REDISMODULE_SUBEVENT_REPLICA_CHANGE_OFFLINE 1
  269 
  270 #define REDISMODULE_EVENT_REPLROLECHANGED_NOW_MASTER 0
  271 #define REDISMODULE_EVENT_REPLROLECHANGED_NOW_REPLICA 1
  272 
  273 #define REDISMODULE_SUBEVENT_FLUSHDB_START 0
  274 #define REDISMODULE_SUBEVENT_FLUSHDB_END 1
  275 
  276 #define REDISMODULE_SUBEVENT_MODULE_LOADED 0
  277 #define REDISMODULE_SUBEVENT_MODULE_UNLOADED 1
  278 
  279 #define REDISMODULE_SUBEVENT_LOADING_PROGRESS_RDB 0
  280 #define REDISMODULE_SUBEVENT_LOADING_PROGRESS_AOF 1
  281 
  282 /* RedisModuleClientInfo flags. */
  283 #define REDISMODULE_CLIENTINFO_FLAG_SSL (1<<0)
  284 #define REDISMODULE_CLIENTINFO_FLAG_PUBSUB (1<<1)
  285 #define REDISMODULE_CLIENTINFO_FLAG_BLOCKED (1<<2)
  286 #define REDISMODULE_CLIENTINFO_FLAG_TRACKING (1<<3)
  287 #define REDISMODULE_CLIENTINFO_FLAG_UNIXSOCKET (1<<4)
  288 #define REDISMODULE_CLIENTINFO_FLAG_MULTI (1<<5)
  289 
  290 /* Here we take all the structures that the module pass to the core
  291  * and the other way around. Notably the list here contains the structures
  292  * used by the hooks API RedisModule_RegisterToServerEvent().
  293  *
  294  * The structures always start with a 'version' field. This is useful
  295  * when we want to pass a reference to the structure to the core APIs,
  296  * for the APIs to fill the structure. In that case, the structure 'version'
  297  * field is initialized before passing it to the core, so that the core is
  298  * able to cast the pointer to the appropriate structure version. In this
  299  * way we obtain ABI compatibility.
  300  *
  301  * Here we'll list all the structure versions in case they evolve over time,
  302  * however using a define, we'll make sure to use the last version as the
  303  * public name for the module to use. */
  304 
  305 #define REDISMODULE_CLIENTINFO_VERSION 1
  306 typedef struct RedisModuleClientInfo {
  307     uint64_t version;       /* Version of this structure for ABI compat. */
  308     uint64_t flags;         /* REDISMODULE_CLIENTINFO_FLAG_* */
  309     uint64_t id;            /* Client ID. */
  310     char addr[46];          /* IPv4 or IPv6 address. */
  311     uint16_t port;          /* TCP port. */
  312     uint16_t db;            /* Selected DB. */
  313 } RedisModuleClientInfoV1;
  314 
  315 #define RedisModuleClientInfo RedisModuleClientInfoV1
  316 
  317 #define REDISMODULE_REPLICATIONINFO_VERSION 1
  318 typedef struct RedisModuleReplicationInfo {
  319     uint64_t version;       /* Not used since this structure is never passed
  320                                from the module to the core right now. Here
  321                                for future compatibility. */
  322     int master;             /* true if master, false if replica */
  323     char *masterhost;       /* master instance hostname for NOW_REPLICA */
  324     int masterport;         /* master instance port for NOW_REPLICA */
  325     char *replid1;          /* Main replication ID */
  326     char *replid2;          /* Secondary replication ID */
  327     uint64_t repl1_offset;  /* Main replication offset */
  328     uint64_t repl2_offset;  /* Offset of replid2 validity */
  329 } RedisModuleReplicationInfoV1;
  330 
  331 #define RedisModuleReplicationInfo RedisModuleReplicationInfoV1
  332 
  333 #define REDISMODULE_FLUSHINFO_VERSION 1
  334 typedef struct RedisModuleFlushInfo {
  335     uint64_t version;       /* Not used since this structure is never passed
  336                                from the module to the core right now. Here
  337                                for future compatibility. */
  338     int32_t sync;           /* Synchronous or threaded flush?. */
  339     int32_t dbnum;          /* Flushed database number, -1 for ALL. */
  340 } RedisModuleFlushInfoV1;
  341 
  342 #define RedisModuleFlushInfo RedisModuleFlushInfoV1
  343 
  344 #define REDISMODULE_MODULE_CHANGE_VERSION 1
  345 typedef struct RedisModuleModuleChange {
  346     uint64_t version;       /* Not used since this structure is never passed
  347                                from the module to the core right now. Here
  348                                for future compatibility. */
  349     const char* module_name;/* Name of module loaded or unloaded. */
  350     int32_t module_version; /* Module version. */
  351 } RedisModuleModuleChangeV1;
  352 
  353 #define RedisModuleModuleChange RedisModuleModuleChangeV1
  354 
  355 #define REDISMODULE_CRON_LOOP_VERSION 1
  356 typedef struct RedisModuleCronLoopInfo {
  357     uint64_t version;       /* Not used since this structure is never passed
  358                                from the module to the core right now. Here
  359                                for future compatibility. */
  360     int32_t hz;             /* Approximate number of events per second. */
  361 } RedisModuleCronLoopV1;
  362 
  363 #define RedisModuleCronLoop RedisModuleCronLoopV1
  364 
  365 #define REDISMODULE_LOADING_PROGRESS_VERSION 1
  366 typedef struct RedisModuleLoadingProgressInfo {
  367     uint64_t version;       /* Not used since this structure is never passed
  368                                from the module to the core right now. Here
  369                                for future compatibility. */
  370     int32_t hz;             /* Approximate number of events per second. */
  371     int32_t progress;       /* Approximate progress between 0 and 1024, or -1
  372                              * if unknown. */
  373 } RedisModuleLoadingProgressV1;
  374 
  375 #define RedisModuleLoadingProgress RedisModuleLoadingProgressV1
  376 
  377 /* ------------------------- End of common defines ------------------------ */
  378 
  379 #ifndef REDISMODULE_CORE
  380 
  381 typedef long long mstime_t;
  382 
  383 /* Macro definitions specific to individual compilers */
  384 #ifndef REDISMODULE_ATTR_UNUSED
  385 #    ifdef __GNUC__
  386 #        define REDISMODULE_ATTR_UNUSED __attribute__((unused))
  387 #    else
  388 #        define REDISMODULE_ATTR_UNUSED
  389 #    endif
  390 #endif
  391 
  392 #ifndef REDISMODULE_ATTR_PRINTF
  393 #    ifdef __GNUC__
  394 #        define REDISMODULE_ATTR_PRINTF(idx,cnt) __attribute__((format(printf,idx,cnt)))
  395 #    else
  396 #        define REDISMODULE_ATTR_PRINTF(idx,cnt)
  397 #    endif
  398 #endif
  399 
  400 #ifndef REDISMODULE_ATTR_COMMON
  401 #    if defined(__GNUC__) && !defined(__clang__)
  402 #        define REDISMODULE_ATTR_COMMON __attribute__((__common__))
  403 #    else
  404 #        define REDISMODULE_ATTR_COMMON
  405 #    endif
  406 #endif
  407 
  408 /* Incomplete structures for compiler checks but opaque access. */
  409 typedef struct RedisModuleCtx RedisModuleCtx;
  410 typedef struct RedisModuleKey RedisModuleKey;
  411 typedef struct RedisModuleString RedisModuleString;
  412 typedef struct RedisModuleCallReply RedisModuleCallReply;
  413 typedef struct RedisModuleIO RedisModuleIO;
  414 typedef struct RedisModuleType RedisModuleType;
  415 typedef struct RedisModuleDigest RedisModuleDigest;
  416 typedef struct RedisModuleBlockedClient RedisModuleBlockedClient;
  417 typedef struct RedisModuleClusterInfo RedisModuleClusterInfo;
  418 typedef struct RedisModuleDict RedisModuleDict;
  419 typedef struct RedisModuleDictIter RedisModuleDictIter;
  420 typedef struct RedisModuleCommandFilterCtx RedisModuleCommandFilterCtx;
  421 typedef struct RedisModuleCommandFilter RedisModuleCommandFilter;
  422 typedef struct RedisModuleInfoCtx RedisModuleInfoCtx;
  423 typedef struct RedisModuleServerInfoData RedisModuleServerInfoData;
  424 typedef struct RedisModuleScanCursor RedisModuleScanCursor;
  425 typedef struct RedisModuleUser RedisModuleUser;
  426 
  427 typedef int (*RedisModuleCmdFunc)(RedisModuleCtx *ctx, RedisModuleString **argv, int argc);
  428 typedef void (*RedisModuleDisconnectFunc)(RedisModuleCtx *ctx, RedisModuleBlockedClient *bc);
  429 typedef int (*RedisModuleNotificationFunc)(RedisModuleCtx *ctx, int type, const char *event, RedisModuleString *key);
  430 typedef void *(*RedisModuleTypeLoadFunc)(RedisModuleIO *rdb, int encver);
  431 typedef void (*RedisModuleTypeSaveFunc)(RedisModuleIO *rdb, void *value);
  432 typedef int (*RedisModuleTypeAuxLoadFunc)(RedisModuleIO *rdb, int encver, int when);
  433 typedef void (*RedisModuleTypeAuxSaveFunc)(RedisModuleIO *rdb, int when);
  434 typedef void (*RedisModuleTypeRewriteFunc)(RedisModuleIO *aof, RedisModuleString *key, void *value);
  435 typedef size_t (*RedisModuleTypeMemUsageFunc)(const void *value);
  436 typedef void (*RedisModuleTypeDigestFunc)(RedisModuleDigest *digest, void *value);
  437 typedef void (*RedisModuleTypeFreeFunc)(void *value);
  438 typedef void (*RedisModuleClusterMessageReceiver)(RedisModuleCtx *ctx, const char *sender_id, uint8_t type, const unsigned char *payload, uint32_t len);
  439 typedef void (*RedisModuleTimerProc)(RedisModuleCtx *ctx, void *data);
  440 typedef void (*RedisModuleCommandFilterFunc) (RedisModuleCommandFilterCtx *filter);
  441 typedef void (*RedisModuleForkDoneHandler) (int exitcode, int bysignal, void *user_data);
  442 typedef void (*RedisModuleInfoFunc)(RedisModuleInfoCtx *ctx, int for_crash_report);
  443 typedef void (*RedisModuleScanCB)(RedisModuleCtx *ctx, RedisModuleString *keyname, RedisModuleKey *key, void *privdata);
  444 typedef void (*RedisModuleScanKeyCB)(RedisModuleKey *key, RedisModuleString *field, RedisModuleString *value, void *privdata);
  445 typedef void (*RedisModuleUserChangedFunc) (uint64_t client_id, void *privdata);
  446 
  447 #define REDISMODULE_TYPE_METHOD_VERSION 2
  448 typedef struct RedisModuleTypeMethods {
  449     uint64_t version;
  450     RedisModuleTypeLoadFunc rdb_load;
  451     RedisModuleTypeSaveFunc rdb_save;
  452     RedisModuleTypeRewriteFunc aof_rewrite;
  453     RedisModuleTypeMemUsageFunc mem_usage;
  454     RedisModuleTypeDigestFunc digest;
  455     RedisModuleTypeFreeFunc free;
  456     RedisModuleTypeAuxLoadFunc aux_load;
  457     RedisModuleTypeAuxSaveFunc aux_save;
  458     int aux_save_triggers;
  459 } RedisModuleTypeMethods;
  460 
  461 #define REDISMODULE_GET_API(name) \
  462     RedisModule_GetApi("RedisModule_" #name, ((void **)&RedisModule_ ## name))
  463 
  464 /* Default API declaration prefix (not 'extern' for backwards compatibility) */
  465 #ifndef REDISMODULE_API
  466 #define REDISMODULE_API
  467 #endif
  468 
  469 /* Default API declaration suffix (compiler attributes) */
  470 #ifndef REDISMODULE_ATTR
  471 #define REDISMODULE_ATTR REDISMODULE_ATTR_COMMON
  472 #endif
  473 
  474 REDISMODULE_API void * (*RedisModule_Alloc)(size_t bytes) REDISMODULE_ATTR;
  475 REDISMODULE_API void * (*RedisModule_Realloc)(void *ptr, size_t bytes) REDISMODULE_ATTR;
  476 REDISMODULE_API void (*RedisModule_Free)(void *ptr) REDISMODULE_ATTR;
  477 REDISMODULE_API void * (*RedisModule_Calloc)(size_t nmemb, size_t size) REDISMODULE_ATTR;
  478 REDISMODULE_API char * (*RedisModule_Strdup)(const char *str) REDISMODULE_ATTR;
  479 REDISMODULE_API int (*RedisModule_GetApi)(const char *, void *) REDISMODULE_ATTR;
  480 REDISMODULE_API int (*RedisModule_CreateCommand)(RedisModuleCtx *ctx, const char *name, RedisModuleCmdFunc cmdfunc, const char *strflags, int firstkey, int lastkey, int keystep) REDISMODULE_ATTR;
  481 REDISMODULE_API void (*RedisModule_SetModuleAttribs)(RedisModuleCtx *ctx, const char *name, int ver, int apiver) REDISMODULE_ATTR;
  482 REDISMODULE_API int (*RedisModule_IsModuleNameBusy)(const char *name) REDISMODULE_ATTR;
  483 REDISMODULE_API int (*RedisModule_WrongArity)(RedisModuleCtx *ctx) REDISMODULE_ATTR;
  484 REDISMODULE_API int (*RedisModule_ReplyWithLongLong)(RedisModuleCtx *ctx, long long ll) REDISMODULE_ATTR;
  485 REDISMODULE_API int (*RedisModule_GetSelectedDb)(RedisModuleCtx *ctx) REDISMODULE_ATTR;
  486 REDISMODULE_API int (*RedisModule_SelectDb)(RedisModuleCtx *ctx, int newid) REDISMODULE_ATTR;
  487 REDISMODULE_API void * (*RedisModule_OpenKey)(RedisModuleCtx *ctx, RedisModuleString *keyname, int mode) REDISMODULE_ATTR;
  488 REDISMODULE_API void (*RedisModule_CloseKey)(RedisModuleKey *kp) REDISMODULE_ATTR;
  489 REDISMODULE_API int (*RedisModule_KeyType)(RedisModuleKey *kp) REDISMODULE_ATTR;
  490 REDISMODULE_API size_t (*RedisModule_ValueLength)(RedisModuleKey *kp) REDISMODULE_ATTR;
  491 REDISMODULE_API int (*RedisModule_ListPush)(RedisModuleKey *kp, int where, RedisModuleString *ele) REDISMODULE_ATTR;
  492 REDISMODULE_API RedisModuleString * (*RedisModule_ListPop)(RedisModuleKey *key, int where) REDISMODULE_ATTR;
  493 REDISMODULE_API RedisModuleCallReply * (*RedisModule_Call)(RedisModuleCtx *ctx, const char *cmdname, const char *fmt, ...) REDISMODULE_ATTR;
  494 REDISMODULE_API const char * (*RedisModule_CallReplyProto)(RedisModuleCallReply *reply, size_t *len) REDISMODULE_ATTR;
  495 REDISMODULE_API void (*RedisModule_FreeCallReply)(RedisModuleCallReply *reply) REDISMODULE_ATTR;
  496 REDISMODULE_API int (*RedisModule_CallReplyType)(RedisModuleCallReply *reply) REDISMODULE_ATTR;
  497 REDISMODULE_API long long (*RedisModule_CallReplyInteger)(RedisModuleCallReply *reply) REDISMODULE_ATTR;
  498 REDISMODULE_API size_t (*RedisModule_CallReplyLength)(RedisModuleCallReply *reply) REDISMODULE_ATTR;
  499 REDISMODULE_API RedisModuleCallReply * (*RedisModule_CallReplyArrayElement)(RedisModuleCallReply *reply, size_t idx) REDISMODULE_ATTR;
  500 REDISMODULE_API RedisModuleString * (*RedisModule_CreateString)(RedisModuleCtx *ctx, const char *ptr, size_t len) REDISMODULE_ATTR;
  501 REDISMODULE_API RedisModuleString * (*RedisModule_CreateStringFromLongLong)(RedisModuleCtx *ctx, long long ll) REDISMODULE_ATTR;
  502 REDISMODULE_API RedisModuleString * (*RedisModule_CreateStringFromDouble)(RedisModuleCtx *ctx, double d) REDISMODULE_ATTR;
  503 REDISMODULE_API RedisModuleString * (*RedisModule_CreateStringFromLongDouble)(RedisModuleCtx *ctx, long double ld, int humanfriendly) REDISMODULE_ATTR;
  504 REDISMODULE_API RedisModuleString * (*RedisModule_CreateStringFromString)(RedisModuleCtx *ctx, const RedisModuleString *str) REDISMODULE_ATTR;
  505 REDISMODULE_API RedisModuleString * (*RedisModule_CreateStringPrintf)(RedisModuleCtx *ctx, const char *fmt, ...) REDISMODULE_ATTR_PRINTF(2,3) REDISMODULE_ATTR;
  506 REDISMODULE_API void (*RedisModule_FreeString)(RedisModuleCtx *ctx, RedisModuleString *str) REDISMODULE_ATTR;
  507 REDISMODULE_API const char * (*RedisModule_StringPtrLen)(const RedisModuleString *str, size_t *len) REDISMODULE_ATTR;
  508 REDISMODULE_API int (*RedisModule_ReplyWithError)(RedisModuleCtx *ctx, const char *err) REDISMODULE_ATTR;
  509 REDISMODULE_API int (*RedisModule_ReplyWithSimpleString)(RedisModuleCtx *ctx, const char *msg) REDISMODULE_ATTR;
  510 REDISMODULE_API int (*RedisModule_ReplyWithArray)(RedisModuleCtx *ctx, long len) REDISMODULE_ATTR;
  511 REDISMODULE_API int (*RedisModule_ReplyWithNullArray)(RedisModuleCtx *ctx) REDISMODULE_ATTR;
  512 REDISMODULE_API int (*RedisModule_ReplyWithEmptyArray)(RedisModuleCtx *ctx) REDISMODULE_ATTR;
  513 REDISMODULE_API void (*RedisModule_ReplySetArrayLength)(RedisModuleCtx *ctx, long len) REDISMODULE_ATTR;
  514 REDISMODULE_API int (*RedisModule_ReplyWithStringBuffer)(RedisModuleCtx *ctx, const char *buf, size_t len) REDISMODULE_ATTR;
  515 REDISMODULE_API int (*RedisModule_ReplyWithCString)(RedisModuleCtx *ctx, const char *buf) REDISMODULE_ATTR;
  516 REDISMODULE_API int (*RedisModule_ReplyWithString)(RedisModuleCtx *ctx, RedisModuleString *str) REDISMODULE_ATTR;
  517 REDISMODULE_API int (*RedisModule_ReplyWithEmptyString)(RedisModuleCtx *ctx) REDISMODULE_ATTR;
  518 REDISMODULE_API int (*RedisModule_ReplyWithVerbatimString)(RedisModuleCtx *ctx, const char *buf, size_t len) REDISMODULE_ATTR;
  519 REDISMODULE_API int (*RedisModule_ReplyWithNull)(RedisModuleCtx *ctx) REDISMODULE_ATTR;
  520 REDISMODULE_API int (*RedisModule_ReplyWithDouble)(RedisModuleCtx *ctx, double d) REDISMODULE_ATTR;
  521 REDISMODULE_API int (*RedisModule_ReplyWithLongDouble)(RedisModuleCtx *ctx, long double d) REDISMODULE_ATTR;
  522 REDISMODULE_API int (*RedisModule_ReplyWithCallReply)(RedisModuleCtx *ctx, RedisModuleCallReply *reply) REDISMODULE_ATTR;
  523 REDISMODULE_API int (*RedisModule_StringToLongLong)(const RedisModuleString *str, long long *ll) REDISMODULE_ATTR;
  524 REDISMODULE_API int (*RedisModule_StringToDouble)(const RedisModuleString *str, double *d) REDISMODULE_ATTR;
  525 REDISMODULE_API int (*RedisModule_StringToLongDouble)(const RedisModuleString *str, long double *d) REDISMODULE_ATTR;
  526 REDISMODULE_API void (*RedisModule_AutoMemory)(RedisModuleCtx *ctx) REDISMODULE_ATTR;
  527 REDISMODULE_API int (*RedisModule_Replicate)(RedisModuleCtx *ctx, const char *cmdname, const char *fmt, ...) REDISMODULE_ATTR;
  528 REDISMODULE_API int (*RedisModule_ReplicateVerbatim)(RedisModuleCtx *ctx) REDISMODULE_ATTR;
  529 REDISMODULE_API const char * (*RedisModule_CallReplyStringPtr)(RedisModuleCallReply *reply, size_t *len) REDISMODULE_ATTR;
  530 REDISMODULE_API RedisModuleString * (*RedisModule_CreateStringFromCallReply)(RedisModuleCallReply *reply) REDISMODULE_ATTR;
  531 REDISMODULE_API int (*RedisModule_DeleteKey)(RedisModuleKey *key) REDISMODULE_ATTR;
  532 REDISMODULE_API int (*RedisModule_UnlinkKey)(RedisModuleKey *key) REDISMODULE_ATTR;
  533 REDISMODULE_API int (*RedisModule_StringSet)(RedisModuleKey *key, RedisModuleString *str) REDISMODULE_ATTR;
  534 REDISMODULE_API char * (*RedisModule_StringDMA)(RedisModuleKey *key, size_t *len, int mode) REDISMODULE_ATTR;
  535 REDISMODULE_API int (*RedisModule_StringTruncate)(RedisModuleKey *key, size_t newlen) REDISMODULE_ATTR;
  536 REDISMODULE_API mstime_t (*RedisModule_GetExpire)(RedisModuleKey *key) REDISMODULE_ATTR;
  537 REDISMODULE_API int (*RedisModule_SetExpire)(RedisModuleKey *key, mstime_t expire) REDISMODULE_ATTR;
  538 REDISMODULE_API void (*RedisModule_ResetDataset)(int restart_aof, int async) REDISMODULE_ATTR;
  539 REDISMODULE_API unsigned long long (*RedisModule_DbSize)(RedisModuleCtx *ctx) REDISMODULE_ATTR;
  540 REDISMODULE_API RedisModuleString * (*RedisModule_RandomKey)(RedisModuleCtx *ctx) REDISMODULE_ATTR;
  541 REDISMODULE_API int (*RedisModule_ZsetAdd)(RedisModuleKey *key, double score, RedisModuleString *ele, int *flagsptr) REDISMODULE_ATTR;
  542 REDISMODULE_API int (*RedisModule_ZsetIncrby)(RedisModuleKey *key, double score, RedisModuleString *ele, int *flagsptr, double *newscore) REDISMODULE_ATTR;
  543 REDISMODULE_API int (*RedisModule_ZsetScore)(RedisModuleKey *key, RedisModuleString *ele, double *score) REDISMODULE_ATTR;
  544 REDISMODULE_API int (*RedisModule_ZsetRem)(RedisModuleKey *key, RedisModuleString *ele, int *deleted) REDISMODULE_ATTR;
  545 REDISMODULE_API void (*RedisModule_ZsetRangeStop)(RedisModuleKey *key) REDISMODULE_ATTR;
  546 REDISMODULE_API int (*RedisModule_ZsetFirstInScoreRange)(RedisModuleKey *key, double min, double max, int minex, int maxex) REDISMODULE_ATTR;
  547 REDISMODULE_API int (*RedisModule_ZsetLastInScoreRange)(RedisModuleKey *key, double min, double max, int minex, int maxex) REDISMODULE_ATTR;
  548 REDISMODULE_API int (*RedisModule_ZsetFirstInLexRange)(RedisModuleKey *key, RedisModuleString *min, RedisModuleString *max) REDISMODULE_ATTR;
  549 REDISMODULE_API int (*RedisModule_ZsetLastInLexRange)(RedisModuleKey *key, RedisModuleString *min, RedisModuleString *max) REDISMODULE_ATTR;
  550 REDISMODULE_API RedisModuleString * (*RedisModule_ZsetRangeCurrentElement)(RedisModuleKey *key, double *score) REDISMODULE_ATTR;
  551 REDISMODULE_API int (*RedisModule_ZsetRangeNext)(RedisModuleKey *key) REDISMODULE_ATTR;
  552 REDISMODULE_API int (*RedisModule_ZsetRangePrev)(RedisModuleKey *key) REDISMODULE_ATTR;
  553 REDISMODULE_API int (*RedisModule_ZsetRangeEndReached)(RedisModuleKey *key) REDISMODULE_ATTR;
  554 REDISMODULE_API int (*RedisModule_HashSet)(RedisModuleKey *key, int flags, ...) REDISMODULE_ATTR;
  555 REDISMODULE_API int (*RedisModule_HashGet)(RedisModuleKey *key, int flags, ...) REDISMODULE_ATTR;
  556 REDISMODULE_API int (*RedisModule_IsKeysPositionRequest)(RedisModuleCtx *ctx) REDISMODULE_ATTR;
  557 REDISMODULE_API void (*RedisModule_KeyAtPos)(RedisModuleCtx *ctx, int pos) REDISMODULE_ATTR;
  558 REDISMODULE_API unsigned long long (*RedisModule_GetClientId)(RedisModuleCtx *ctx) REDISMODULE_ATTR;
  559 REDISMODULE_API int (*RedisModule_GetClientInfoById)(void *ci, uint64_t id) REDISMODULE_ATTR;
  560 REDISMODULE_API int (*RedisModule_PublishMessage)(RedisModuleCtx *ctx, RedisModuleString *channel, RedisModuleString *message) REDISMODULE_ATTR;
  561 REDISMODULE_API int (*RedisModule_GetContextFlags)(RedisModuleCtx *ctx) REDISMODULE_ATTR;
  562 REDISMODULE_API int (*RedisModule_AvoidReplicaTraffic)() REDISMODULE_ATTR;
  563 REDISMODULE_API void * (*RedisModule_PoolAlloc)(RedisModuleCtx *ctx, size_t bytes) REDISMODULE_ATTR;
  564 REDISMODULE_API RedisModuleType * (*RedisModule_CreateDataType)(RedisModuleCtx *ctx, const char *name, int encver, RedisModuleTypeMethods *typemethods) REDISMODULE_ATTR;
  565 REDISMODULE_API int (*RedisModule_ModuleTypeSetValue)(RedisModuleKey *key, RedisModuleType *mt, void *value) REDISMODULE_ATTR;
  566 REDISMODULE_API int (*RedisModule_ModuleTypeReplaceValue)(RedisModuleKey *key, RedisModuleType *mt, void *new_value, void **old_value) REDISMODULE_ATTR;
  567 REDISMODULE_API RedisModuleType * (*RedisModule_ModuleTypeGetType)(RedisModuleKey *key) REDISMODULE_ATTR;
  568 REDISMODULE_API void * (*RedisModule_ModuleTypeGetValue)(RedisModuleKey *key) REDISMODULE_ATTR;
  569 REDISMODULE_API int (*RedisModule_IsIOError)(RedisModuleIO *io) REDISMODULE_ATTR;
  570 REDISMODULE_API void (*RedisModule_SetModuleOptions)(RedisModuleCtx *ctx, int options) REDISMODULE_ATTR;
  571 REDISMODULE_API int (*RedisModule_SignalModifiedKey)(RedisModuleCtx *ctx, RedisModuleString *keyname) REDISMODULE_ATTR;
  572 REDISMODULE_API void (*RedisModule_SaveUnsigned)(RedisModuleIO *io, uint64_t value) REDISMODULE_ATTR;
  573 REDISMODULE_API uint64_t (*RedisModule_LoadUnsigned)(RedisModuleIO *io) REDISMODULE_ATTR;
  574 REDISMODULE_API void (*RedisModule_SaveSigned)(RedisModuleIO *io, int64_t value) REDISMODULE_ATTR;
  575 REDISMODULE_API int64_t (*RedisModule_LoadSigned)(RedisModuleIO *io) REDISMODULE_ATTR;
  576 REDISMODULE_API void (*RedisModule_EmitAOF)(RedisModuleIO *io, const char *cmdname, const char *fmt, ...) REDISMODULE_ATTR;
  577 REDISMODULE_API void (*RedisModule_SaveString)(RedisModuleIO *io, RedisModuleString *s) REDISMODULE_ATTR;
  578 REDISMODULE_API void (*RedisModule_SaveStringBuffer)(RedisModuleIO *io, const char *str, size_t len) REDISMODULE_ATTR;
  579 REDISMODULE_API RedisModuleString * (*RedisModule_LoadString)(RedisModuleIO *io) REDISMODULE_ATTR;
  580 REDISMODULE_API char * (*RedisModule_LoadStringBuffer)(RedisModuleIO *io, size_t *lenptr) REDISMODULE_ATTR;
  581 REDISMODULE_API void (*RedisModule_SaveDouble)(RedisModuleIO *io, double value) REDISMODULE_ATTR;
  582 REDISMODULE_API double (*RedisModule_LoadDouble)(RedisModuleIO *io) REDISMODULE_ATTR;
  583 REDISMODULE_API void (*RedisModule_SaveFloat)(RedisModuleIO *io, float value) REDISMODULE_ATTR;
  584 REDISMODULE_API float (*RedisModule_LoadFloat)(RedisModuleIO *io) REDISMODULE_ATTR;
  585 REDISMODULE_API void (*RedisModule_SaveLongDouble)(RedisModuleIO *io, long double value) REDISMODULE_ATTR;
  586 REDISMODULE_API long double (*RedisModule_LoadLongDouble)(RedisModuleIO *io) REDISMODULE_ATTR;
  587 REDISMODULE_API void * (*RedisModule_LoadDataTypeFromString)(const RedisModuleString *str, const RedisModuleType *mt) REDISMODULE_ATTR;
  588 REDISMODULE_API RedisModuleString * (*RedisModule_SaveDataTypeToString)(RedisModuleCtx *ctx, void *data, const RedisModuleType *mt) REDISMODULE_ATTR;
  589 REDISMODULE_API void (*RedisModule_Log)(RedisModuleCtx *ctx, const char *level, const char *fmt, ...) REDISMODULE_ATTR REDISMODULE_ATTR_PRINTF(3,4);
  590 REDISMODULE_API void (*RedisModule_LogIOError)(RedisModuleIO *io, const char *levelstr, const char *fmt, ...) REDISMODULE_ATTR REDISMODULE_ATTR_PRINTF(3,4);
  591 REDISMODULE_API void (*RedisModule__Assert)(const char *estr, const char *file, int line) REDISMODULE_ATTR;
  592 REDISMODULE_API void (*RedisModule_LatencyAddSample)(const char *event, mstime_t latency) REDISMODULE_ATTR;
  593 REDISMODULE_API int (*RedisModule_StringAppendBuffer)(RedisModuleCtx *ctx, RedisModuleString *str, const char *buf, size_t len) REDISMODULE_ATTR;
  594 REDISMODULE_API void (*RedisModule_RetainString)(RedisModuleCtx *ctx, RedisModuleString *str) REDISMODULE_ATTR;
  595 REDISMODULE_API RedisModuleString * (*RedisModule_HoldString)(RedisModuleCtx *ctx, RedisModuleString *str) REDISMODULE_ATTR;
  596 REDISMODULE_API int (*RedisModule_StringCompare)(RedisModuleString *a, RedisModuleString *b) REDISMODULE_ATTR;
  597 REDISMODULE_API RedisModuleCtx * (*RedisModule_GetContextFromIO)(RedisModuleIO *io) REDISMODULE_ATTR;
  598 REDISMODULE_API const RedisModuleString * (*RedisModule_GetKeyNameFromIO)(RedisModuleIO *io) REDISMODULE_ATTR;
  599 REDISMODULE_API const RedisModuleString * (*RedisModule_GetKeyNameFromModuleKey)(RedisModuleKey *key) REDISMODULE_ATTR;
  600 REDISMODULE_API long long (*RedisModule_Milliseconds)(void) REDISMODULE_ATTR;
  601 REDISMODULE_API void (*RedisModule_DigestAddStringBuffer)(RedisModuleDigest *md, unsigned char *ele, size_t len) REDISMODULE_ATTR;
  602 REDISMODULE_API void (*RedisModule_DigestAddLongLong)(RedisModuleDigest *md, long long ele) REDISMODULE_ATTR;
  603 REDISMODULE_API void (*RedisModule_DigestEndSequence)(RedisModuleDigest *md) REDISMODULE_ATTR;
  604 REDISMODULE_API RedisModuleDict * (*RedisModule_CreateDict)(RedisModuleCtx *ctx) REDISMODULE_ATTR;
  605 REDISMODULE_API void (*RedisModule_FreeDict)(RedisModuleCtx *ctx, RedisModuleDict *d) REDISMODULE_ATTR;
  606 REDISMODULE_API uint64_t (*RedisModule_DictSize)(RedisModuleDict *d) REDISMODULE_ATTR;
  607 REDISMODULE_API int (*RedisModule_DictSetC)(RedisModuleDict *d, void *key, size_t keylen, void *ptr) REDISMODULE_ATTR;
  608 REDISMODULE_API int (*RedisModule_DictReplaceC)(RedisModuleDict *d, void *key, size_t keylen, void *ptr) REDISMODULE_ATTR;
  609 REDISMODULE_API int (*RedisModule_DictSet)(RedisModuleDict *d, RedisModuleString *key, void *ptr) REDISMODULE_ATTR;
  610 REDISMODULE_API int (*RedisModule_DictReplace)(RedisModuleDict *d, RedisModuleString *key, void *ptr) REDISMODULE_ATTR;
  611 REDISMODULE_API void * (*RedisModule_DictGetC)(RedisModuleDict *d, void *key, size_t keylen, int *nokey) REDISMODULE_ATTR;
  612 REDISMODULE_API void * (*RedisModule_DictGet)(RedisModuleDict *d, RedisModuleString *key, int *nokey) REDISMODULE_ATTR;
  613 REDISMODULE_API int (*RedisModule_DictDelC)(RedisModuleDict *d, void *key, size_t keylen, void *oldval) REDISMODULE_ATTR;
  614 REDISMODULE_API int (*RedisModule_DictDel)(RedisModuleDict *d, RedisModuleString *key, void *oldval) REDISMODULE_ATTR;
  615 REDISMODULE_API RedisModuleDictIter * (*RedisModule_DictIteratorStartC)(RedisModuleDict *d, const char *op, void *key, size_t keylen) REDISMODULE_ATTR;
  616 REDISMODULE_API RedisModuleDictIter * (*RedisModule_DictIteratorStart)(RedisModuleDict *d, const char *op, RedisModuleString *key) REDISMODULE_ATTR;
  617 REDISMODULE_API void (*RedisModule_DictIteratorStop)(RedisModuleDictIter *di) REDISMODULE_ATTR;
  618 REDISMODULE_API int (*RedisModule_DictIteratorReseekC)(RedisModuleDictIter *di, const char *op, void *key, size_t keylen) REDISMODULE_ATTR;
  619 REDISMODULE_API int (*RedisModule_DictIteratorReseek)(RedisModuleDictIter *di, const char *op, RedisModuleString *key) REDISMODULE_ATTR;
  620 REDISMODULE_API void * (*RedisModule_DictNextC)(RedisModuleDictIter *di, size_t *keylen, void **dataptr) REDISMODULE_ATTR;
  621 REDISMODULE_API void * (*RedisModule_DictPrevC)(RedisModuleDictIter *di, size_t *keylen, void **dataptr) REDISMODULE_ATTR;
  622 REDISMODULE_API RedisModuleString * (*RedisModule_DictNext)(RedisModuleCtx *ctx, RedisModuleDictIter *di, void **dataptr) REDISMODULE_ATTR;
  623 REDISMODULE_API RedisModuleString * (*RedisModule_DictPrev)(RedisModuleCtx *ctx, RedisModuleDictIter *di, void **dataptr) REDISMODULE_ATTR;
  624 REDISMODULE_API int (*RedisModule_DictCompareC)(RedisModuleDictIter *di, const char *op, void *key, size_t keylen) REDISMODULE_ATTR;
  625 REDISMODULE_API int (*RedisModule_DictCompare)(RedisModuleDictIter *di, const char *op, RedisModuleString *key) REDISMODULE_ATTR;
  626 REDISMODULE_API int (*RedisModule_RegisterInfoFunc)(RedisModuleCtx *ctx, RedisModuleInfoFunc cb) REDISMODULE_ATTR;
  627 REDISMODULE_API int (*RedisModule_InfoAddSection)(RedisModuleInfoCtx *ctx, char *name) REDISMODULE_ATTR;
  628 REDISMODULE_API int (*RedisModule_InfoBeginDictField)(RedisModuleInfoCtx *ctx, char *name) REDISMODULE_ATTR;
  629 REDISMODULE_API int (*RedisModule_InfoEndDictField)(RedisModuleInfoCtx *ctx) REDISMODULE_ATTR;
  630 REDISMODULE_API int (*RedisModule_InfoAddFieldString)(RedisModuleInfoCtx *ctx, char *field, RedisModuleString *value) REDISMODULE_ATTR;
  631 REDISMODULE_API int (*RedisModule_InfoAddFieldCString)(RedisModuleInfoCtx *ctx, char *field, char *value) REDISMODULE_ATTR;
  632 REDISMODULE_API int (*RedisModule_InfoAddFieldDouble)(RedisModuleInfoCtx *ctx, char *field, double value) REDISMODULE_ATTR;
  633 REDISMODULE_API int (*RedisModule_InfoAddFieldLongLong)(RedisModuleInfoCtx *ctx, char *field, long long value) REDISMODULE_ATTR;
  634 REDISMODULE_API int (*RedisModule_InfoAddFieldULongLong)(RedisModuleInfoCtx *ctx, char *field, unsigned long long value) REDISMODULE_ATTR;
  635 REDISMODULE_API RedisModuleServerInfoData * (*RedisModule_GetServerInfo)(RedisModuleCtx *ctx, const char *section) REDISMODULE_ATTR;
  636 REDISMODULE_API void (*RedisModule_FreeServerInfo)(RedisModuleCtx *ctx, RedisModuleServerInfoData *data) REDISMODULE_ATTR;
  637 REDISMODULE_API RedisModuleString * (*RedisModule_ServerInfoGetField)(RedisModuleCtx *ctx, RedisModuleServerInfoData *data, const char* field) REDISMODULE_ATTR;
  638 REDISMODULE_API const char * (*RedisModule_ServerInfoGetFieldC)(RedisModuleServerInfoData *data, const char* field) REDISMODULE_ATTR;
  639 REDISMODULE_API long long (*RedisModule_ServerInfoGetFieldSigned)(RedisModuleServerInfoData *data, const char* field, int *out_err) REDISMODULE_ATTR;
  640 REDISMODULE_API unsigned long long (*RedisModule_ServerInfoGetFieldUnsigned)(RedisModuleServerInfoData *data, const char* field, int *out_err) REDISMODULE_ATTR;
  641 REDISMODULE_API double (*RedisModule_ServerInfoGetFieldDouble)(RedisModuleServerInfoData *data, const char* field, int *out_err) REDISMODULE_ATTR;
  642 REDISMODULE_API int (*RedisModule_SubscribeToServerEvent)(RedisModuleCtx *ctx, RedisModuleEvent event, RedisModuleEventCallback callback) REDISMODULE_ATTR;
  643 REDISMODULE_API int (*RedisModule_SetLRU)(RedisModuleKey *key, mstime_t lru_idle) REDISMODULE_ATTR;
  644 REDISMODULE_API int (*RedisModule_GetLRU)(RedisModuleKey *key, mstime_t *lru_idle) REDISMODULE_ATTR;
  645 REDISMODULE_API int (*RedisModule_SetLFU)(RedisModuleKey *key, long long lfu_freq) REDISMODULE_ATTR;
  646 REDISMODULE_API int (*RedisModule_GetLFU)(RedisModuleKey *key, long long *lfu_freq) REDISMODULE_ATTR;
  647 REDISMODULE_API RedisModuleBlockedClient * (*RedisModule_BlockClientOnKeys)(RedisModuleCtx *ctx, RedisModuleCmdFunc reply_callback, RedisModuleCmdFunc timeout_callback, void (*free_privdata)(RedisModuleCtx*,void*), long long timeout_ms, RedisModuleString **keys, int numkeys, void *privdata) REDISMODULE_ATTR;
  648 REDISMODULE_API void (*RedisModule_SignalKeyAsReady)(RedisModuleCtx *ctx, RedisModuleString *key) REDISMODULE_ATTR;
  649 REDISMODULE_API RedisModuleString * (*RedisModule_GetBlockedClientReadyKey)(RedisModuleCtx *ctx) REDISMODULE_ATTR;
  650 REDISMODULE_API RedisModuleScanCursor * (*RedisModule_ScanCursorCreate)() REDISMODULE_ATTR;
  651 REDISMODULE_API void (*RedisModule_ScanCursorRestart)(RedisModuleScanCursor *cursor) REDISMODULE_ATTR;
  652 REDISMODULE_API void (*RedisModule_ScanCursorDestroy)(RedisModuleScanCursor *cursor) REDISMODULE_ATTR;
  653 REDISMODULE_API int (*RedisModule_Scan)(RedisModuleCtx *ctx, RedisModuleScanCursor *cursor, RedisModuleScanCB fn, void *privdata) REDISMODULE_ATTR;
  654 REDISMODULE_API int (*RedisModule_ScanKey)(RedisModuleKey *key, RedisModuleScanCursor *cursor, RedisModuleScanKeyCB fn, void *privdata) REDISMODULE_ATTR;
  655 
  656 /* Experimental APIs */
  657 #ifdef REDISMODULE_EXPERIMENTAL_API
  658 #define REDISMODULE_EXPERIMENTAL_API_VERSION 3
  659 REDISMODULE_API RedisModuleBlockedClient * (*RedisModule_BlockClient)(RedisModuleCtx *ctx, RedisModuleCmdFunc reply_callback, RedisModuleCmdFunc timeout_callback, void (*free_privdata)(RedisModuleCtx*,void*), long long timeout_ms) REDISMODULE_ATTR;
  660 REDISMODULE_API int (*RedisModule_UnblockClient)(RedisModuleBlockedClient *bc, void *privdata) REDISMODULE_ATTR;
  661 REDISMODULE_API int (*RedisModule_IsBlockedReplyRequest)(RedisModuleCtx *ctx) REDISMODULE_ATTR;
  662 REDISMODULE_API int (*RedisModule_IsBlockedTimeoutRequest)(RedisModuleCtx *ctx) REDISMODULE_ATTR;
  663 REDISMODULE_API void * (*RedisModule_GetBlockedClientPrivateData)(RedisModuleCtx *ctx) REDISMODULE_ATTR;
  664 REDISMODULE_API RedisModuleBlockedClient * (*RedisModule_GetBlockedClientHandle)(RedisModuleCtx *ctx) REDISMODULE_ATTR;
  665 REDISMODULE_API int (*RedisModule_AbortBlock)(RedisModuleBlockedClient *bc) REDISMODULE_ATTR;
  666 REDISMODULE_API RedisModuleCtx * (*RedisModule_GetThreadSafeContext)(RedisModuleBlockedClient *bc) REDISMODULE_ATTR;
  667 REDISMODULE_API void (*RedisModule_FreeThreadSafeContext)(RedisModuleCtx *ctx) REDISMODULE_ATTR;
  668 REDISMODULE_API void (*RedisModule_ThreadSafeContextLock)(RedisModuleCtx *ctx) REDISMODULE_ATTR;
  669 REDISMODULE_API int (*RedisModule_ThreadSafeContextTryLock)(RedisModuleCtx *ctx) REDISMODULE_ATTR;
  670 REDISMODULE_API void (*RedisModule_ThreadSafeContextUnlock)(RedisModuleCtx *ctx) REDISMODULE_ATTR;
  671 REDISMODULE_API int (*RedisModule_SubscribeToKeyspaceEvents)(RedisModuleCtx *ctx, int types, RedisModuleNotificationFunc cb) REDISMODULE_ATTR;
  672 REDISMODULE_API int (*RedisModule_NotifyKeyspaceEvent)(RedisModuleCtx *ctx, int type, const char *event, RedisModuleString *key) REDISMODULE_ATTR;
  673 REDISMODULE_API int (*RedisModule_GetNotifyKeyspaceEvents)() REDISMODULE_ATTR;
  674 REDISMODULE_API int (*RedisModule_BlockedClientDisconnected)(RedisModuleCtx *ctx) REDISMODULE_ATTR;
  675 REDISMODULE_API void (*RedisModule_RegisterClusterMessageReceiver)(RedisModuleCtx *ctx, uint8_t type, RedisModuleClusterMessageReceiver callback) REDISMODULE_ATTR;
  676 REDISMODULE_API int (*RedisModule_SendClusterMessage)(RedisModuleCtx *ctx, char *target_id, uint8_t type, unsigned char *msg, uint32_t len) REDISMODULE_ATTR;
  677 REDISMODULE_API int (*RedisModule_GetClusterNodeInfo)(RedisModuleCtx *ctx, const char *id, char *ip, char *master_id, int *port, int *flags) REDISMODULE_ATTR;
  678 REDISMODULE_API char ** (*RedisModule_GetClusterNodesList)(RedisModuleCtx *ctx, size_t *numnodes) REDISMODULE_ATTR;
  679 REDISMODULE_API void (*RedisModule_FreeClusterNodesList)(char **ids) REDISMODULE_ATTR;
  680 REDISMODULE_API RedisModuleTimerID (*RedisModule_CreateTimer)(RedisModuleCtx *ctx, mstime_t period, RedisModuleTimerProc callback, void *data) REDISMODULE_ATTR;
  681 REDISMODULE_API int (*RedisModule_StopTimer)(RedisModuleCtx *ctx, RedisModuleTimerID id, void **data) REDISMODULE_ATTR;
  682 REDISMODULE_API int (*RedisModule_GetTimerInfo)(RedisModuleCtx *ctx, RedisModuleTimerID id, uint64_t *remaining, void **data) REDISMODULE_ATTR;
  683 REDISMODULE_API const char * (*RedisModule_GetMyClusterID)(void) REDISMODULE_ATTR;
  684 REDISMODULE_API size_t (*RedisModule_GetClusterSize)(void) REDISMODULE_ATTR;
  685 REDISMODULE_API void (*RedisModule_GetRandomBytes)(unsigned char *dst, size_t len) REDISMODULE_ATTR;
  686 REDISMODULE_API void (*RedisModule_GetRandomHexChars)(char *dst, size_t len) REDISMODULE_ATTR;
  687 REDISMODULE_API void (*RedisModule_SetDisconnectCallback)(RedisModuleBlockedClient *bc, RedisModuleDisconnectFunc callback) REDISMODULE_ATTR;
  688 REDISMODULE_API void (*RedisModule_SetClusterFlags)(RedisModuleCtx *ctx, uint64_t flags) REDISMODULE_ATTR;
  689 REDISMODULE_API int (*RedisModule_ExportSharedAPI)(RedisModuleCtx *ctx, const char *apiname, void *func) REDISMODULE_ATTR;
  690 REDISMODULE_API void * (*RedisModule_GetSharedAPI)(RedisModuleCtx *ctx, const char *apiname) REDISMODULE_ATTR;
  691 REDISMODULE_API RedisModuleCommandFilter * (*RedisModule_RegisterCommandFilter)(RedisModuleCtx *ctx, RedisModuleCommandFilterFunc cb, int flags) REDISMODULE_ATTR;
  692 REDISMODULE_API int (*RedisModule_UnregisterCommandFilter)(RedisModuleCtx *ctx, RedisModuleCommandFilter *filter) REDISMODULE_ATTR;
  693 REDISMODULE_API int (*RedisModule_CommandFilterArgsCount)(RedisModuleCommandFilterCtx *fctx) REDISMODULE_ATTR;
  694 REDISMODULE_API const RedisModuleString * (*RedisModule_CommandFilterArgGet)(RedisModuleCommandFilterCtx *fctx, int pos) REDISMODULE_ATTR;
  695 REDISMODULE_API int (*RedisModule_CommandFilterArgInsert)(RedisModuleCommandFilterCtx *fctx, int pos, RedisModuleString *arg) REDISMODULE_ATTR;
  696 REDISMODULE_API int (*RedisModule_CommandFilterArgReplace)(RedisModuleCommandFilterCtx *fctx, int pos, RedisModuleString *arg) REDISMODULE_ATTR;
  697 REDISMODULE_API int (*RedisModule_CommandFilterArgDelete)(RedisModuleCommandFilterCtx *fctx, int pos) REDISMODULE_ATTR;
  698 REDISMODULE_API int (*RedisModule_Fork)(RedisModuleForkDoneHandler cb, void *user_data) REDISMODULE_ATTR;
  699 REDISMODULE_API int (*RedisModule_ExitFromChild)(int retcode) REDISMODULE_ATTR;
  700 REDISMODULE_API int (*RedisModule_KillForkChild)(int child_pid) REDISMODULE_ATTR;
  701 REDISMODULE_API float (*RedisModule_GetUsedMemoryRatio)() REDISMODULE_ATTR;
  702 REDISMODULE_API size_t (*RedisModule_MallocSize)(void* ptr) REDISMODULE_ATTR;
  703 REDISMODULE_API RedisModuleUser * (*RedisModule_CreateModuleUser)(const char *name) REDISMODULE_ATTR;
  704 REDISMODULE_API void (*RedisModule_FreeModuleUser)(RedisModuleUser *user) REDISMODULE_ATTR;
  705 REDISMODULE_API int (*RedisModule_SetModuleUserACL)(RedisModuleUser *user, const char* acl) REDISMODULE_ATTR;
  706 REDISMODULE_API int (*RedisModule_AuthenticateClientWithACLUser)(RedisModuleCtx *ctx, const char *name, size_t len, RedisModuleUserChangedFunc callback, void *privdata, uint64_t *client_id) REDISMODULE_ATTR;
  707 REDISMODULE_API int (*RedisModule_AuthenticateClientWithUser)(RedisModuleCtx *ctx, RedisModuleUser *user, RedisModuleUserChangedFunc callback, void *privdata, uint64_t *client_id) REDISMODULE_ATTR;
  708 REDISMODULE_API int (*RedisModule_DeauthenticateAndCloseClient)(RedisModuleCtx *ctx, uint64_t client_id) REDISMODULE_ATTR;
  709 #endif
  710 
  711 #define RedisModule_IsAOFClient(id) ((id) == CLIENT_ID_AOF)
  712 
  713 /* This is included inline inside each Redis module. */
  714 static int RedisModule_Init(RedisModuleCtx *ctx, const char *name, int ver, int apiver) REDISMODULE_ATTR_UNUSED;
  715 static int RedisModule_Init(RedisModuleCtx *ctx, const char *name, int ver, int apiver) {
  716     void *getapifuncptr = ((void**)ctx)[0];
  717     RedisModule_GetApi = (int (*)(const char *, void *)) (unsigned long)getapifuncptr;
  718     REDISMODULE_GET_API(Alloc);
  719     REDISMODULE_GET_API(Calloc);
  720     REDISMODULE_GET_API(Free);
  721     REDISMODULE_GET_API(Realloc);
  722     REDISMODULE_GET_API(Strdup);
  723     REDISMODULE_GET_API(CreateCommand);
  724     REDISMODULE_GET_API(SetModuleAttribs);
  725     REDISMODULE_GET_API(IsModuleNameBusy);
  726     REDISMODULE_GET_API(WrongArity);
  727     REDISMODULE_GET_API(ReplyWithLongLong);
  728     REDISMODULE_GET_API(ReplyWithError);
  729     REDISMODULE_GET_API(ReplyWithSimpleString);
  730     REDISMODULE_GET_API(ReplyWithArray);
  731     REDISMODULE_GET_API(ReplyWithNullArray);
  732     REDISMODULE_GET_API(ReplyWithEmptyArray);
  733     REDISMODULE_GET_API(ReplySetArrayLength);
  734     REDISMODULE_GET_API(ReplyWithStringBuffer);
  735     REDISMODULE_GET_API(ReplyWithCString);
  736     REDISMODULE_GET_API(ReplyWithString);
  737     REDISMODULE_GET_API(ReplyWithEmptyString);
  738     REDISMODULE_GET_API(ReplyWithVerbatimString);
  739     REDISMODULE_GET_API(ReplyWithNull);
  740     REDISMODULE_GET_API(ReplyWithCallReply);
  741     REDISMODULE_GET_API(ReplyWithDouble);
  742     REDISMODULE_GET_API(ReplyWithLongDouble);
  743     REDISMODULE_GET_API(GetSelectedDb);
  744     REDISMODULE_GET_API(SelectDb);
  745     REDISMODULE_GET_API(OpenKey);
  746     REDISMODULE_GET_API(CloseKey);
  747     REDISMODULE_GET_API(KeyType);
  748     REDISMODULE_GET_API(ValueLength);
  749     REDISMODULE_GET_API(ListPush);
  750     REDISMODULE_GET_API(ListPop);
  751     REDISMODULE_GET_API(StringToLongLong);
  752     REDISMODULE_GET_API(StringToDouble);
  753     REDISMODULE_GET_API(StringToLongDouble);
  754     REDISMODULE_GET_API(Call);
  755     REDISMODULE_GET_API(CallReplyProto);
  756     REDISMODULE_GET_API(FreeCallReply);
  757     REDISMODULE_GET_API(CallReplyInteger);
  758     REDISMODULE_GET_API(CallReplyType);
  759     REDISMODULE_GET_API(CallReplyLength);
  760     REDISMODULE_GET_API(CallReplyArrayElement);
  761     REDISMODULE_GET_API(CallReplyStringPtr);
  762     REDISMODULE_GET_API(CreateStringFromCallReply);
  763     REDISMODULE_GET_API(CreateString);
  764     REDISMODULE_GET_API(CreateStringFromLongLong);
  765     REDISMODULE_GET_API(CreateStringFromDouble);
  766     REDISMODULE_GET_API(CreateStringFromLongDouble);
  767     REDISMODULE_GET_API(CreateStringFromString);
  768     REDISMODULE_GET_API(CreateStringPrintf);
  769     REDISMODULE_GET_API(FreeString);
  770     REDISMODULE_GET_API(StringPtrLen);
  771     REDISMODULE_GET_API(AutoMemory);
  772     REDISMODULE_GET_API(Replicate);
  773     REDISMODULE_GET_API(ReplicateVerbatim);
  774     REDISMODULE_GET_API(DeleteKey);
  775     REDISMODULE_GET_API(UnlinkKey);
  776     REDISMODULE_GET_API(StringSet);
  777     REDISMODULE_GET_API(StringDMA);
  778     REDISMODULE_GET_API(StringTruncate);
  779     REDISMODULE_GET_API(GetExpire);
  780     REDISMODULE_GET_API(SetExpire);
  781     REDISMODULE_GET_API(ResetDataset);
  782     REDISMODULE_GET_API(DbSize);
  783     REDISMODULE_GET_API(RandomKey);
  784     REDISMODULE_GET_API(ZsetAdd);
  785     REDISMODULE_GET_API(ZsetIncrby);
  786     REDISMODULE_GET_API(ZsetScore);
  787     REDISMODULE_GET_API(ZsetRem);
  788     REDISMODULE_GET_API(ZsetRangeStop);
  789     REDISMODULE_GET_API(ZsetFirstInScoreRange);
  790     REDISMODULE_GET_API(ZsetLastInScoreRange);
  791     REDISMODULE_GET_API(ZsetFirstInLexRange);
  792     REDISMODULE_GET_API(ZsetLastInLexRange);
  793     REDISMODULE_GET_API(ZsetRangeCurrentElement);
  794     REDISMODULE_GET_API(ZsetRangeNext);
  795     REDISMODULE_GET_API(ZsetRangePrev);
  796     REDISMODULE_GET_API(ZsetRangeEndReached);
  797     REDISMODULE_GET_API(HashSet);
  798     REDISMODULE_GET_API(HashGet);
  799     REDISMODULE_GET_API(IsKeysPositionRequest);
  800     REDISMODULE_GET_API(KeyAtPos);
  801     REDISMODULE_GET_API(GetClientId);
  802     REDISMODULE_GET_API(GetContextFlags);
  803     REDISMODULE_GET_API(AvoidReplicaTraffic);
  804     REDISMODULE_GET_API(PoolAlloc);
  805     REDISMODULE_GET_API(CreateDataType);
  806     REDISMODULE_GET_API(ModuleTypeSetValue);
  807     REDISMODULE_GET_API(ModuleTypeReplaceValue);
  808     REDISMODULE_GET_API(ModuleTypeGetType);
  809     REDISMODULE_GET_API(ModuleTypeGetValue);
  810     REDISMODULE_GET_API(IsIOError);
  811     REDISMODULE_GET_API(SetModuleOptions);
  812     REDISMODULE_GET_API(SignalModifiedKey);
  813     REDISMODULE_GET_API(SaveUnsigned);
  814     REDISMODULE_GET_API(LoadUnsigned);
  815     REDISMODULE_GET_API(SaveSigned);
  816     REDISMODULE_GET_API(LoadSigned);
  817     REDISMODULE_GET_API(SaveString);
  818     REDISMODULE_GET_API(SaveStringBuffer);
  819     REDISMODULE_GET_API(LoadString);
  820     REDISMODULE_GET_API(LoadStringBuffer);
  821     REDISMODULE_GET_API(SaveDouble);
  822     REDISMODULE_GET_API(LoadDouble);
  823     REDISMODULE_GET_API(SaveFloat);
  824     REDISMODULE_GET_API(LoadFloat);
  825     REDISMODULE_GET_API(SaveLongDouble);
  826     REDISMODULE_GET_API(LoadLongDouble);
  827     REDISMODULE_GET_API(SaveDataTypeToString);
  828     REDISMODULE_GET_API(LoadDataTypeFromString);
  829     REDISMODULE_GET_API(EmitAOF);
  830     REDISMODULE_GET_API(Log);
  831     REDISMODULE_GET_API(LogIOError);
  832     REDISMODULE_GET_API(_Assert);
  833     REDISMODULE_GET_API(LatencyAddSample);
  834     REDISMODULE_GET_API(StringAppendBuffer);
  835     REDISMODULE_GET_API(RetainString);
  836     REDISMODULE_GET_API(HoldString);
  837     REDISMODULE_GET_API(StringCompare);
  838     REDISMODULE_GET_API(GetContextFromIO);
  839     REDISMODULE_GET_API(GetKeyNameFromIO);
  840     REDISMODULE_GET_API(GetKeyNameFromModuleKey);
  841     REDISMODULE_GET_API(Milliseconds);
  842     REDISMODULE_GET_API(DigestAddStringBuffer);
  843     REDISMODULE_GET_API(DigestAddLongLong);
  844     REDISMODULE_GET_API(DigestEndSequence);
  845     REDISMODULE_GET_API(CreateDict);
  846     REDISMODULE_GET_API(FreeDict);
  847     REDISMODULE_GET_API(DictSize);
  848     REDISMODULE_GET_API(DictSetC);
  849     REDISMODULE_GET_API(DictReplaceC);
  850     REDISMODULE_GET_API(DictSet);
  851     REDISMODULE_GET_API(DictReplace);
  852     REDISMODULE_GET_API(DictGetC);
  853     REDISMODULE_GET_API(DictGet);
  854     REDISMODULE_GET_API(DictDelC);
  855     REDISMODULE_GET_API(DictDel);
  856     REDISMODULE_GET_API(DictIteratorStartC);
  857     REDISMODULE_GET_API(DictIteratorStart);
  858     REDISMODULE_GET_API(DictIteratorStop);
  859     REDISMODULE_GET_API(DictIteratorReseekC);
  860     REDISMODULE_GET_API(DictIteratorReseek);
  861     REDISMODULE_GET_API(DictNextC);
  862     REDISMODULE_GET_API(DictPrevC);
  863     REDISMODULE_GET_API(DictNext);
  864     REDISMODULE_GET_API(DictPrev);
  865     REDISMODULE_GET_API(DictCompare);
  866     REDISMODULE_GET_API(DictCompareC);
  867     REDISMODULE_GET_API(RegisterInfoFunc);
  868     REDISMODULE_GET_API(InfoAddSection);
  869     REDISMODULE_GET_API(InfoBeginDictField);
  870     REDISMODULE_GET_API(InfoEndDictField);
  871     REDISMODULE_GET_API(InfoAddFieldString);
  872     REDISMODULE_GET_API(InfoAddFieldCString);
  873     REDISMODULE_GET_API(InfoAddFieldDouble);
  874     REDISMODULE_GET_API(InfoAddFieldLongLong);
  875     REDISMODULE_GET_API(InfoAddFieldULongLong);
  876     REDISMODULE_GET_API(GetServerInfo);
  877     REDISMODULE_GET_API(FreeServerInfo);
  878     REDISMODULE_GET_API(ServerInfoGetField);
  879     REDISMODULE_GET_API(ServerInfoGetFieldC);
  880     REDISMODULE_GET_API(ServerInfoGetFieldSigned);
  881     REDISMODULE_GET_API(ServerInfoGetFieldUnsigned);
  882     REDISMODULE_GET_API(ServerInfoGetFieldDouble);
  883     REDISMODULE_GET_API(GetClientInfoById);
  884     REDISMODULE_GET_API(PublishMessage);
  885     REDISMODULE_GET_API(SubscribeToServerEvent);
  886     REDISMODULE_GET_API(SetLRU);
  887     REDISMODULE_GET_API(GetLRU);
  888     REDISMODULE_GET_API(SetLFU);
  889     REDISMODULE_GET_API(GetLFU);
  890     REDISMODULE_GET_API(BlockClientOnKeys);
  891     REDISMODULE_GET_API(SignalKeyAsReady);
  892     REDISMODULE_GET_API(GetBlockedClientReadyKey);
  893     REDISMODULE_GET_API(ScanCursorCreate);
  894     REDISMODULE_GET_API(ScanCursorRestart);
  895     REDISMODULE_GET_API(ScanCursorDestroy);
  896     REDISMODULE_GET_API(Scan);
  897     REDISMODULE_GET_API(ScanKey);
  898 
  899 #ifdef REDISMODULE_EXPERIMENTAL_API
  900     REDISMODULE_GET_API(GetThreadSafeContext);
  901     REDISMODULE_GET_API(FreeThreadSafeContext);
  902     REDISMODULE_GET_API(ThreadSafeContextLock);
  903     REDISMODULE_GET_API(ThreadSafeContextTryLock);
  904     REDISMODULE_GET_API(ThreadSafeContextUnlock);
  905     REDISMODULE_GET_API(BlockClient);
  906     REDISMODULE_GET_API(UnblockClient);
  907     REDISMODULE_GET_API(IsBlockedReplyRequest);
  908     REDISMODULE_GET_API(IsBlockedTimeoutRequest);
  909     REDISMODULE_GET_API(GetBlockedClientPrivateData);
  910     REDISMODULE_GET_API(GetBlockedClientHandle);
  911     REDISMODULE_GET_API(AbortBlock);
  912     REDISMODULE_GET_API(SetDisconnectCallback);
  913     REDISMODULE_GET_API(SubscribeToKeyspaceEvents);
  914     REDISMODULE_GET_API(NotifyKeyspaceEvent);
  915     REDISMODULE_GET_API(GetNotifyKeyspaceEvents);
  916     REDISMODULE_GET_API(BlockedClientDisconnected);
  917     REDISMODULE_GET_API(RegisterClusterMessageReceiver);
  918     REDISMODULE_GET_API(SendClusterMessage);
  919     REDISMODULE_GET_API(GetClusterNodeInfo);
  920     REDISMODULE_GET_API(GetClusterNodesList);
  921     REDISMODULE_GET_API(FreeClusterNodesList);
  922     REDISMODULE_GET_API(CreateTimer);
  923     REDISMODULE_GET_API(StopTimer);
  924     REDISMODULE_GET_API(GetTimerInfo);
  925     REDISMODULE_GET_API(GetMyClusterID);
  926     REDISMODULE_GET_API(GetClusterSize);
  927     REDISMODULE_GET_API(GetRandomBytes);
  928     REDISMODULE_GET_API(GetRandomHexChars);
  929     REDISMODULE_GET_API(SetClusterFlags);
  930     REDISMODULE_GET_API(ExportSharedAPI);
  931     REDISMODULE_GET_API(GetSharedAPI);
  932     REDISMODULE_GET_API(RegisterCommandFilter);
  933     REDISMODULE_GET_API(UnregisterCommandFilter);
  934     REDISMODULE_GET_API(CommandFilterArgsCount);
  935     REDISMODULE_GET_API(CommandFilterArgGet);
  936     REDISMODULE_GET_API(CommandFilterArgInsert);
  937     REDISMODULE_GET_API(CommandFilterArgReplace);
  938     REDISMODULE_GET_API(CommandFilterArgDelete);
  939     REDISMODULE_GET_API(Fork);
  940     REDISMODULE_GET_API(ExitFromChild);
  941     REDISMODULE_GET_API(KillForkChild);
  942     REDISMODULE_GET_API(GetUsedMemoryRatio);
  943     REDISMODULE_GET_API(MallocSize);
  944     REDISMODULE_GET_API(CreateModuleUser);
  945     REDISMODULE_GET_API(FreeModuleUser);
  946     REDISMODULE_GET_API(SetModuleUserACL);
  947     REDISMODULE_GET_API(DeauthenticateAndCloseClient);
  948     REDISMODULE_GET_API(AuthenticateClientWithACLUser);
  949     REDISMODULE_GET_API(AuthenticateClientWithUser);
  950 #endif
  951 
  952     if (RedisModule_IsModuleNameBusy && RedisModule_IsModuleNameBusy(name)) return REDISMODULE_ERR;
  953     RedisModule_SetModuleAttribs(ctx,name,ver,apiver);
  954     return REDISMODULE_OK;
  955 }
  956 
  957 #define RedisModule_Assert(_e) ((_e)?(void)0 : (RedisModule__Assert(#_e,__FILE__,__LINE__),exit(1)))
  958 
  959 #else
  960 
  961 /* Things only defined for the modules core, not exported to modules
  962  * including this file. */
  963 #define RedisModuleString robj
  964 
  965 #endif /* REDISMODULE_CORE */
  966 #endif /* REDISMOUDLE_H */