Skip to content


Subversion checkout URL

You can clone with
Download ZIP

Merge pull request #38 from marcooliveira/patch-1

[fix] location is shared between instances
latest commit d923291e1c
@nolanlawson nolanlawson authored


LevelDB Logo

A drop-in replacement for LevelDOWN that works in memory only. Can be used as a back-end for LevelUP rather than an actual LevelDB store.




As of version 0.7, LevelUP allows you to pass a 'db' option when you create a new instance. This will override the default LevelDOWN store with a LevelDOWN API compatible object. MemDOWN conforms exactly to the LevelDOWN API but only performs operations in memory, so your data is discarded when the process ends or you release a reference to the database.


var levelup = require('levelup')
  // note that if multiple instances point to the same location,
  // the db will be shared, but only per process
  , db = levelup('/some/location', { db: require('memdown') })

db.put('name', 'Yuri Irsenovich Kim')
db.put('dob', '16 February 1941')
db.put('spouse', 'Kim Young-sook')
db.put('occupation', 'Clown')

  .on('data', console.log)
  .on('close', function () { console.log('Show\'s over folks!') })

Note in this example we're not even bothering to use callbacks on our .put() methods even though they are async. We know that MemDOWN operates immediately so the data will go straight into the store.

Running our example gives:

{ key: 'dob', value: '16 February 1941' }
{ key: 'name', value: 'Yuri Irsenovich Kim' }
{ key: 'occupation', value: 'Clown' }
{ key: 'spouse', value: 'Kim Young-sook' }
Show's over folks!


MemDOWN is Copyright (c) 2013-2015 Rod Vagg @rvagg and licensed under the MIT licence. All rights not explicitly granted in the MIT license are reserved. See the included LICENSE file for more details.

Something went wrong with that request. Please try again.