No description
Find a file
2021-07-24 00:03:03 -04:00
src added macro redis v0.2.0 2021-07-24 00:03:03 -04:00
README.md updating README.md 2021-06-04 12:09:02 -04:00
redismodules.nimble added macro redis v0.2.0 2021-07-24 00:03:03 -04:00

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 ;)