Skip to content

Instantly share code, notes, and snippets.

View yannick's full-sized avatar
🏗️

Yannick Koechlin yannick

🏗️
View GitHub Profile

Creating a redis Module in 15 lines of code!

A quick guide to write a very very simple "ECHO" style module to redis and load it. It's not really useful of course, but the idea is to illustrate how little boilerplate it takes.

Step 1: open your favorite editor and write/paste the following code in a file called module.c

#include "redismodule.h"
/* ECHO <string> - Echo back a string sent from the client */
int EchoCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) {
import std.stdio;
import asdf;
void main(string[] args)
{
auto fileName = (args.length > 1) ? args[1] : "./mock/data.jsonl";
filterByLine(fileName);
}
## Refer to http://caffe.berkeleyvision.org/installation.html
# Contributions simplifying and improving our build system are welcome!
# cuDNN acceleration switch (uncomment to build with cuDNN).
# USE_CUDNN := 1
# CPU-only switch (uncomment to build without GPU support).
CPU_ONLY := 1
# uncomment to disable IO dependencies and corresponding data layers
## Refer to http://caffe.berkeleyvision.org/installation.html
# Contributions simplifying and improving our build system are welcome!
# cuDNN acceleration switch (uncomment to build with cuDNN).
# USE_CUDNN := 1
# CPU-only switch (uncomment to build without GPU support).
CPU_ONLY := 1
# uncomment to disable IO dependencies and corresponding data layers
## Refer to http://caffe.berkeleyvision.org/installation.html
# Contributions simplifying and improving our build system are welcome!
# cuDNN acceleration switch (uncomment to build with cuDNN).
# USE_CUDNN := 1
# CPU-only switch (uncomment to build without GPU support).
CPU_ONLY := 1
# uncomment to disable IO dependencies and corresponding data layers
/* hyperloglog.c - Redis HyperLogLog probabilistic cardinality approximation.
* This file implements the algorithm and the exported Redis commands.
*
* Copyright (c) 2014, Salvatore Sanfilippo <antirez at gmail dot com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
import std.stdio : stdin;
auto lines = stdin.byLine();
foreach(line; lines)
{
import parser : parse;
string rawJson = cast(string) line;
string will_be_garbage = rawJson["a"][0].get!string;
}
import std.csv;
import std.stdio;
import std.datetime;
import std.conv;
/*
reads logfiles from nginx that are generated with:
log_format metrics '$msec\t$connection\t$status\t$request_time\t$remote_addr\t$remote_port\t$body_bytes_sent\t$request_uri\t$tcpinfo_rtt\t$tcpinfo_rttvar\t$tcpinfo_snd_cwnd\t$tcpinfo_rcv_space';
*/
alias ColumnName = string;
HLLMap[ColumnName] counters;
alias HashOfTags = string;
alias HLLMap = HLLWrapper[HashOfTags];
//HLLWrapper is a Class
if (! (cnt.columnName in counters))
{
counters[cnt.columnName] = [tags: new HLLWrapper()];
}
{
"rootPackage": "streamcard",
"mainPackage": "streamcard",
"configuration": "application",
"buildType": "debug",
"compiler": "dmd",
"architecture": [
"x86_64"
],
"platform": [