Skip to content

Instantly share code, notes, and snippets.

Avatar

Kyle Getson kylegetson

View GitHub Profile
@kylegetson
kylegetson / gist:5599722
Created May 17, 2013
get or set example
View gist:5599722
var levelup = require('levelup');
var db = levelup('./mydb', {cacheSize: 0});
function getOrSet(num){
if( num == 0 ) return;
var hash = num.toString();
db.get(hash, function(err,result){
@kylegetson
kylegetson / gist:5599592
Created May 17, 2013
similar issue with leveldb (level down)
View gist:5599592
var levelup = require('levelup')
, crypto = require('crypto');
var db = levelup('./mydb', {cacheSize: 0});
function uniqueGet(num){
if( num == 0 ) return;
var hash = crypto.createHash('md5').update( num.toString() ).digest("hex");
@kylegetson
kylegetson / gist:5595268
Created May 16, 2013
memory leak example in levelup. Repeatedly getting the same key from leveldb. This will consume 100M in memory within 45 seconds, and continues to grow the more you call db.get()
View gist:5595268
var levelup = require('levelup')
, crypto = require('crypto');
var db = levelup('./mydb', {cacheSize: 0});
// assuming this key exists
var str = "whatever";
var hash = crypto.createHash('md5').update( str ).digest("hex");
function sameGet(num){
You can’t perform that action at this time.