"Fossies" - the Fresh Open Source Software Archive

Member "redis-6.2.5/src/redismodule.h" (21 Jul 2021, 66774 Bytes) of package /linux/misc/redis-6.2.5.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.2.4_vs_6.2.5.

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