This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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){ |