@@ -2664,22 +2664,22 @@ int TairHashTypeActiveExpireInfo_RedisCommand(RedisModuleCtx *ctx, RedisModuleSt
26642664 ctx ,
26652665 "\r\n"
26662666 "# Active expire statistics\r\n"
2667- "enable_active_expire:%d \r\n"
2668- "tair_hash_active_expire_period:%lld \r\n"
2669- "tair_hash_active_expire_keys_per_loop:%lld \r\n"
2670- "tair_hash_active_expire_dbs_per_loop:%lld \r\n"
2671- "tair_hash_active_expire_last_time_msec:%lld \r\n"
2672- "tair_hash_active_expire_max_time_msec:%lld \r\n"
2673- "tair_hash_active_expire_avg_time_msec:%lld \r\n"
2674- "tair_hash_passive_expire_keys_per_loop:%lld \r\n" ,
2675- g_expire_algorithm .enable_active_expire ,
2676- g_expire_algorithm .active_expire_period ,
2677- g_expire_algorithm .keys_per_active_loop ,
2678- g_expire_algorithm .dbs_per_active_loop ,
2679- g_expire_algorithm .stat_last_active_expire_time_msec ,
2680- g_expire_algorithm .stat_max_active_expire_time_msec ,
2681- g_expire_algorithm .stat_avg_active_expire_time_msec ,
2682- g_expire_algorithm .keys_per_passive_loop );
2667+ "enable_active_expire:%ld \r\n"
2668+ "tair_hash_active_expire_period:%ld \r\n"
2669+ "tair_hash_active_expire_keys_per_loop:%ld \r\n"
2670+ "tair_hash_active_expire_dbs_per_loop:%ld \r\n"
2671+ "tair_hash_active_expire_last_time_msec:%ld \r\n"
2672+ "tair_hash_active_expire_max_time_msec:%ld \r\n"
2673+ "tair_hash_active_expire_avg_time_msec:%ld \r\n"
2674+ "tair_hash_passive_expire_keys_per_loop:%ld \r\n" ,
2675+ ( long ) g_expire_algorithm .enable_active_expire ,
2676+ ( long ) g_expire_algorithm .active_expire_period ,
2677+ ( long ) g_expire_algorithm .keys_per_active_loop ,
2678+ ( long ) g_expire_algorithm .dbs_per_active_loop ,
2679+ ( long ) g_expire_algorithm .stat_last_active_expire_time_msec ,
2680+ ( long ) g_expire_algorithm .stat_max_active_expire_time_msec ,
2681+ ( long ) g_expire_algorithm .stat_avg_active_expire_time_msec ,
2682+ ( long ) g_expire_algorithm .keys_per_passive_loop );
26832683
26842684 size_t a_len , d_len , t_size = 0 ;
26852685 const char * a_buf = RedisModule_StringPtrLen (info_a , & a_len );
@@ -2892,6 +2892,51 @@ size_t TairHashTypeEffort2(RedisModuleKeyOptCtx *ctx, const void *value) {
28922892 tairHashObj * o = (tairHashObj * )value ;
28932893 return dictSize (o -> hash ) + o -> expire_index -> length ;
28942894}
2895+ #else
2896+
2897+ size_t TairHashTypeMemUsage (const void * value ) {
2898+ tairHashObj * o = (tairHashObj * )value ;
2899+
2900+ uint64_t size = 0 ;
2901+ RedisModuleString * skey ;
2902+ size_t skeylen = 0 ;
2903+
2904+ if (!o ) {
2905+ return size ;
2906+ }
2907+
2908+ m_dictIterator * di ;
2909+ m_dictEntry * de ;
2910+
2911+ if (o -> hash ) {
2912+ size += sizeof (* o );
2913+
2914+ di = m_dictGetIterator (o -> hash );
2915+ while ((de = m_dictNext (di )) != NULL ) {
2916+ TairHashVal * val = (TairHashVal * )dictGetVal (de );
2917+ skey = dictGetKey (de );
2918+ size += sizeof (* val );
2919+ RedisModule_StringPtrLen (skey , & skeylen );
2920+ size += skeylen ;
2921+ size_t len ;
2922+ RedisModule_StringPtrLen (val -> value , & len );
2923+ size += len ;
2924+ }
2925+ m_dictReleaseIterator (di );
2926+ }
2927+
2928+ if (o -> expire_index ) {
2929+ size += o -> expire_index -> length * sizeof (m_zskiplistNode );
2930+ }
2931+
2932+ return size ;
2933+ }
2934+
2935+ size_t TairHashTypeEffort (RedisModuleString * key , const void * value ) {
2936+ REDISMODULE_NOT_USED (key );
2937+ tairHashObj * o = (tairHashObj * )value ;
2938+ return dictSize (o -> hash ) + o -> expire_index -> length ;
2939+ }
28952940
28962941#endif
28972942
@@ -3061,6 +3106,9 @@ int __attribute__((visibility("default"))) RedisModule_OnLoad(RedisModuleCtx *ct
30613106 .copy2 = TairHashTypeCopy2 ,
30623107 .free_effort2 = TairHashTypeEffort2 ,
30633108 .mem_usage2 = TairHashTypeMemUsage2 ,
3109+ #else
3110+ .mem_usage = TairHashTypeMemUsage ,
3111+ .free_effort = TairHashTypeEffort ,
30643112#endif
30653113 };
30663114
0 commit comments