summaryrefslogtreecommitdiff
path: root/src/redismodule.h
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2016-08-02 15:29:04 +0200
committerantirez <antirez@gmail.com>2016-08-02 15:29:04 +0200
commit7829e4ed2c4cda26a9891216ecf97c0b6e637195 (patch)
tree3545d3faf69cc844aa08b35702dc94cb33c5ff7e /src/redismodule.h
parentd982f443727bb226652d5c6a8320ed1962df1727 (diff)
downloadredis-7829e4ed2c4cda26a9891216ecf97c0b6e637195.tar.gz
Modules: StringAppendBuffer() and ability to retain strings.
RedisModule_StringRetain() allows, when automatic memory management is on, to keep string objects living after the callback returns. Can also be used in order to use Redis reference counting of objects inside modules. The reason why this is useful is that sometimes when implementing new data types we want to reference RedisModuleString objects inside the module private data structures, so those string objects must be valid after the callback returns even if not referenced inside the Redis key space.
Diffstat (limited to 'src/redismodule.h')
-rw-r--r--src/redismodule.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/redismodule.h b/src/redismodule.h
index fd9e46dc6..b368049d1 100644
--- a/src/redismodule.h
+++ b/src/redismodule.h
@@ -184,6 +184,8 @@ char *REDISMODULE_API_FUNC(RedisModule_LoadStringBuffer)(RedisModuleIO *io, size
void REDISMODULE_API_FUNC(RedisModule_SaveDouble)(RedisModuleIO *io, double value);
double REDISMODULE_API_FUNC(RedisModule_LoadDouble)(RedisModuleIO *io);
void REDISMODULE_API_FUNC(RedisModule_Log)(RedisModuleCtx *ctx, const char *level, const char *fmt, ...);
+int REDISMODULE_API_FUNC(RedisModule_StringAppendBuffer)(RedisModuleCtx *ctx, RedisModuleString *str, const char *buf, size_t len);
+void REDISMODULE_API_FUNC(RedisModule_RetainString)(RedisModuleCtx *ctx, RedisModuleString *str);
/* This is included inline inside each Redis module. */
static int RedisModule_Init(RedisModuleCtx *ctx, const char *name, int ver, int apiver) __attribute__((unused));
@@ -277,6 +279,8 @@ static int RedisModule_Init(RedisModuleCtx *ctx, const char *name, int ver, int
REDISMODULE_GET_API(LoadDouble);
REDISMODULE_GET_API(EmitAOF);
REDISMODULE_GET_API(Log);
+ REDISMODULE_GET_API(StringAppendBuffer);
+ REDISMODULE_GET_API(RetainString);
RedisModule_SetModuleAttribs(ctx,name,ver,apiver);
return REDISMODULE_OK;