@@ -596,6 +596,42 @@ typedef struct RedisModuleTypeMethods {
596596#define REDISMODULE_ATTR REDISMODULE_ATTR_COMMON
597597#endif
598598
599+
600+ /* bigredis extensions
601+ * -------------------*/
602+ #define REDISMODULE_METADATA_NOT_ON_SWAP 0x80
603+ /* Notification that a key's value is added to ram (from swap or otherwise).
604+ * swap_key_flags has 4 bits that the module can write / read.
605+ * when swap_key_metadata is NOT_ON_SWAP, it means the key is not loaded from swap. */
606+ typedef void (* RedisModuleTypeKeyAddedToDbDictFunc )(RedisModuleCtx * ctx , RedisModuleString * key , void * value , int swap_key_metadata );
607+ /* Notification that a key's value is removed from ram (may still exist on swap).
608+ * when swap_key_metadata is NOT_ON_SWAP it means the key does not exist on swap.
609+ * return swap_key_metadata or NOT_ON_SWAP if key is to be deleted (and not to be written). */
610+ typedef int (* RedisModuleTypeRemovingKeyFromDbDictFunc )(RedisModuleCtx * ctx , RedisModuleString * key , void * value , int swap_key_metadata , int writing_to_swap );
611+ /* return swap_key_metadata, 0 indicates nothing to write. when out_min_expire is -1 it indicates nothing to write. */
612+ typedef int (* RedisModuleTypeGetKeyMetadataForRdbFunc )(RedisModuleCtx * ctx , RedisModuleString * key , void * value , long long * out_min_expire , long long * out_max_expire );
613+
614+ #define REDISMODULE_TYPE_EXT_METHOD_VERSION 1
615+ typedef struct RedisModuleTypeExtMethods {
616+ uint64_t version ;
617+ RedisModuleTypeKeyAddedToDbDictFunc key_added_to_db_dict ;
618+ RedisModuleTypeRemovingKeyFromDbDictFunc removing_key_from_db_dict ;
619+ RedisModuleTypeGetKeyMetadataForRdbFunc get_key_metadata_for_rdb ;
620+ } RedisModuleTypeExtMethods ;
621+
622+ REDISMODULE_API int (* RedisModule_SetDataTypeExtensions )(RedisModuleCtx * ctx , RedisModuleType * mt , RedisModuleTypeExtMethods * typemethods ) REDISMODULE_ATTR ;
623+
624+ typedef void (* RedisModuleSwapPrefetchCB )(RedisModuleCtx * ctx , RedisModuleString * key , void * user_data );
625+
626+ REDISMODULE_API int (* RedisModule_SwapPrefetchKey )(RedisModuleCtx * ctx , RedisModuleString * keyname , RedisModuleSwapPrefetchCB fn , void * user_data , int flags ) REDISMODULE_ATTR ;
627+ REDISMODULE_API int (* RedisModule_GetSwapKeyMetadata )(RedisModuleCtx * ctx , RedisModuleString * key ) REDISMODULE_ATTR ;
628+ REDISMODULE_API int (* RedisModule_SetSwapKeyMetadata )(RedisModuleCtx * ctx , RedisModuleString * key , int module_metadata ) REDISMODULE_ATTR ;
629+ REDISMODULE_API int (* RedisModule_IsKeyInRam )(RedisModuleCtx * ctx , RedisModuleString * key ) REDISMODULE_ATTR ;
630+
631+ /* bigredis extensions end
632+ * -------------------*/
633+
634+
599635REDISMODULE_API void * (* RedisModule_Alloc )(size_t bytes ) REDISMODULE_ATTR ;
600636REDISMODULE_API void * (* RedisModule_Realloc )(void * ptr , size_t bytes ) REDISMODULE_ATTR ;
601637REDISMODULE_API void (* RedisModule_Free )(void * ptr ) REDISMODULE_ATTR ;
0 commit comments