Skip to content

Instantly share code, notes, and snippets.

Didier Spezia dspezia

Block or report user

Report or block dspezia

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@dspezia
dspezia / Makefile
Created Feb 23, 2012
Example of pipelining with hiredis
View Makefile
OBJ = genload.o
BINS = genload
CC=g++
OPTIMIZATION?=-O3
CFLAGS?=$(OPTIMIZATION) $(ARCH) $(PROF) -I ../hiredis
CCLINK?=-pthread
LDFLAGS?=-L../hiredis -lhiredis -lm
OBJ = example.o
@dspezia
dspezia / Example log
Created Apr 9, 2012
Assessing pending activity of a Redis server
View Example log
> ~/tcp_redis_monitor.py 6379
Timestamp Nb TX bytes RX bytes TX RMA RX RMA
1333983822.943 1 0 0 0.000 0.000
1333983823.193 1 0 0 0.000 0.000
1333983824.194 1 0 0 0.000 0.000
1333983825.195 1 0 0 0.000 0.000
1333983826.196 1 0 0 0.000 0.000
@dspezia
dspezia / db.c
Created Aug 4, 2012
Redis hack to get notified when a key expire
View db.c
// Change propagateExpire function in db.c as follows:
void propagateExpire(redisDb *db, robj *key) {
/* HORRIBLE HACK STARTS HERE */
/* robj *argv[2]; */
robj *argv[3];
/* HORRIBLE HACK ENDS HERE */
argv[0] = shared.del;
@dspezia
dspezia / tst.cpp
Created Dec 10, 2011
Variadic rpush C++ hiredis example
View tst.cpp
#include <iostream>
#include <vector>
#include <string>
#include <stdexcept>
#include <hiredis.h>
using namespace std;
@dspezia
dspezia / example.c
Created Nov 26, 2012
Example of Redis zset polling daemon
View example.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <signal.h>
#include <time.h>
#include "hiredis.h"
#include "async.h"
#include "adapters/ae.h"
#include "sha1.h"
@dspezia
dspezia / gist:1771342
Created Feb 8, 2012
Example of Redis zset + key iteration + pipelining in Python
View gist:1771342
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# ----------------------------------------------------
import redis, random
POOL = redis.ConnectionPool(host='localhost', port=6379, db=0)
NUSERS = 10000
NTAGS = 500
@dspezia
dspezia / intset.js
Created Jun 19, 2012
Evaluating memory consumption of 1M targeted tag sets
View intset.js
var redis = require('redis')
var rc = redis.createClient(6379, 'localhost');
function create( target, callback )
{
x = []
for ( var i=0; i<40; ++i )
{
// Only 100K entries in the reverse index
var n = 1000*Math.round(Math.random()*100000);
@dspezia
dspezia / example.c
Created Apr 25, 2013
Example if hiredis subscribe with libevent
View example.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <signal.h>
#include "hiredis.h"
#include "async.h"
#include "adapters/libevent.h"
void subCallback(redisAsyncContext *c, void *r, void *priv) {
redisReply *reply = r;
@dspezia
dspezia / mytest.c
Created Apr 1, 2012
Example of async hiredis with libevent
View mytest.c
/*
Based on code provided by Sebastian Sito in stackoverflow question:
http://stackoverflow.com/questions/9958589/async-redis-pooling-using-lib-event
*/
#include <stdlib.h>
#include <event2/event.h>
#include <event2/http.h>
#include <event2/buffer.h>
#include <hiredis/hiredis.h>
@dspezia
dspezia / gist:993738
Created May 26, 2011
Example of pipelining with async hiredis
View gist:993738
/* Code borrowed from hiredis examples */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <signal.h>
#include "hiredis.h"
#include "async.h"
#include "adapters/ae.h"
You can’t perform that action at this time.