Skip to content

Instantly share code, notes, and snippets.

Mark Nunberg mnunberg

  • Redis Labs
  • Orlando, FL
Block or report user

Report or block mnunberg

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
@mnunberg
mnunberg / redismodule.h
Created Nov 22, 2018
redismodule.h using extern and proper declaration vs. definition separation
View redismodule.h
#ifndef REDISMODULE_H
#define REDISMODULE_H
#include <sys/types.h>
#include <stdint.h>
#include <stdio.h>
#ifdef __cplusplus
extern "C" {
#endif
@mnunberg
mnunberg / gist:d78c50d3e526d36d5393
Created Mar 2, 2016
Subdoc multi packet format
View gist:d78c50d3e526d36d5393
# key: mutateIn_REPLACE_Test
# op[0]: SUBDOC_REPLACE(foo, "car")
# op[1]: SUBDOC_REPLACE(foo, "car")
Operation STORE: Success (Not an error)
performing mutations..
Dumping packet..(kh_span: 45. val: 32
[0]: {0x80 (h)} {128 (d)}
[1]: {0xD1 (h)} {209 (d)}
[2]: {0x0 (h)} {0 (d)}
@mnunberg
mnunberg / gen_stmt_file.py
Last active Sep 4, 2015
n1qlback file generator
View gen_stmt_file.py
#!/usr/bin/env python
from argparse import ArgumentParser
import hashlib
import json
import sys
import os
from couchbase.bucket import Bucket
@mnunberg
mnunberg / cmdwrap.h
Created Jun 9, 2015
libcouchbase ABI-Safe command wrappers
View cmdwrap.h
/*
* Copyright 2015 Couchbase, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@mnunberg
mnunberg / lcb-cxx-example.cpp
Created Apr 13, 2015
C++ libcouchbase API example
View lcb-cxx-example.cpp
#include <libcouchbase/couchbase++.h>
#include <libcouchbase/couchbase++/views.h>
#include <libcouchbase/couchbase++/endure.h>
#include <cassert>
#include <iostream>
#include <vector>
using std::cout;
using std::cerr;
using std::endl;
@mnunberg
mnunberg / n1ql-ryow.c
Last active Aug 29, 2015
N1QL read-your-writes with C
View n1ql-ryow.c
/*
* Simple C "script" showing how to connect to Couchbase 4.0 cluster and
* execute a N1QL query. This also creates the primary index which should
* be executed only once.
*
* If you try to run this against an older cluster (e.g. 3.0.x) you will get
* an LCB_NOT_SUPPORTED error (Operation not supported).
*
* Compile and link with couchbase (-lcouchbase). This requires libcouchbase
* version 2.4.8 or greater
@mnunberg
mnunberg / ryow.py
Last active Aug 29, 2015
N1QL Read-Your-Writes with Python 2.0
View ryow.py
#!/usr/bin/env python
"""
Connect to a Couchbase 4.0 cluster and issue a N1QL query.
Note that primary index creation will fail.
"""
import sys
from time import time
from pprint import pprint
from couchbase.bucket import Bucket
View n1ql-sample.c
#include <stdlib.h>
#include <stdio.h>
#include <assert.h>
#include <libcouchbase/couchbase.h>
#include <libcouchbase/n1ql.h>
#define CONNSTR "couchbase://localhost:12000/beer-sample"
static void rowCallback(lcb_t instance, int cbtype, const lcb_RESPN1QL *resp) {
if (! (resp->rflags & LCB_RESP_F_FINAL)) {
@mnunberg
mnunberg / beer-sample.c
Created Feb 19, 2015
lcb-views-beer-sample
View beer-sample.c
#include <stdlib.h>
#include <stdio.h>
#include <assert.h>
#include <libcouchbase/couchbase.h>
#include <libcouchbase/views.h>
#define CONNSTR "couchbase://localhost:12000/beer-sample"
static void rowCallback(lcb_t instance, int cbtype, const lcb_RESPVIEWQUERY *resp) {
if (! (resp->rflags & LCB_RESP_F_FINAL)) {
@mnunberg
mnunberg / lcb-connmgmt.md
Last active Aug 29, 2015
libcouchbase Connection Management
View lcb-connmgmt.md

Connection Management in libcouchbase

This document explains how the library handles TCP connections internally. This will cover both HTTP and Memcached connections

Memcached Sockets

Bootstrapping

During initial bootstrap, the library effectively loops over the list of hosts twice,

You can’t perform that action at this time.