Skip to content

Latest commit

 

History

History
39 lines (31 loc) · 907 Bytes

README.md

File metadata and controls

39 lines (31 loc) · 907 Bytes

redismodules

Develop redis modules in Nimlang (WIP)

Usage

Install redismodules

nimble install redismodules@#head 

Write your module

import redismodules

proc HelloRedis(ctx: ptr Ctx, argv: ptr ptr String, argc: cint):cint {. exportc, dynlib .} =
    result = ReplyWithSimpleString(ctx,"nimlang redismodule ;)")

proc RedisModule_OnLoad(ctx: ptr Ctx, argv: ptr ptr String, argc: cint):cint {. exportc, dynlib .} =
     discard Init(ctx,"helloworld",1,1)
     result = CreateCommand(ctx,"helloworld.hello", HelloRedis, "readonly",0, 0, 0)

Build a dynamic library

nim c -d:release --app:lib [filename.nim]

Load your dynlib into your redis server

redis-server --loadmodule [fullpath of your module].so
#output 
* Module 'helloworld' loaded 

Start using your module

127.0.0.1:6379> helloworld.hello
#nimlang redismodule ;)