Skip to content

luisacosta828/redismodules

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 

Repository files navigation

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

About

Build redismodules using Nim

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages