Skip to content

Instantly share code, notes, and snippets.

@kristoff-it
Created May 8, 2019 17:52
Show Gist options
  • Save kristoff-it/449b5e3a0283f6c9a4e443abe441482b to your computer and use it in GitHub Desktop.
Save kristoff-it/449b5e3a0283f6c9a4e443abe441482b to your computer and use it in GitHub Desktop.
const redis = @cImport({
@cInclude("./redismodule.h");
});
export fn HelloWorld_Command(ctx: *redis.RedisModuleCtx, argv: [*c]*redis.RedisModuleString, argc: c_int) c_int {
_ = redis.RedisModule_ReplyWithSimpleString(ctx, c"Hello World!");
return redis.REDISMODULE_OK;
}
export fn RedisModule_OnLoad(ctx: *redis.RedisModuleCtx, argv: [*c]*redis.RedisModuleString, argc: c_int) c_int {
if (redis.RedisModule_Init(ctx, c"testmodule", 1, redis.REDISMODULE_APIVER_1)
== redis.REDISMODULE_ERR) {
return redis.REDISMODULE_ERR;
}
if (redis.RedisModule_CreateCommand(ctx, c"test.hello", HelloWorld_Command,
c"readonly", 0, 0, 0) == redis.REDISMODULE_ERR) {
return redis.REDISMODULE_ERR;
}
return redis.REDISMODULE_OK;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment