Security News
PyPI Introduces Digital Attestations to Strengthen Python Package Security
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
memdown is an in-memory backend for the LevelUP library, which provides a simple and efficient way to store and retrieve data in memory. It is particularly useful for testing and development purposes where persistence is not required.
Basic Operations
This feature allows you to perform basic operations such as putting, getting, and deleting key-value pairs in the in-memory database.
const levelup = require('levelup');
const memdown = require('memdown');
const db = levelup(memdown());
// Put a value
await db.put('key', 'value');
// Get a value
const value = await db.get('key');
console.log(value); // 'value'
// Delete a value
await db.del('key');
Batch Operations
This feature allows you to perform multiple operations in a single batch, which can be more efficient than performing them individually.
const levelup = require('levelup');
const memdown = require('memdown');
const db = levelup(memdown());
// Perform batch operations
await db.batch()
.put('key1', 'value1')
.put('key2', 'value2')
.del('key1')
.write();
// Get a value
const value = await db.get('key2');
console.log(value); // 'value2'
Stream Operations
This feature allows you to create streams to read data from the database, which can be useful for processing large amounts of data efficiently.
const levelup = require('levelup');
const memdown = require('memdown');
const db = levelup(memdown());
// Put some values
await db.put('key1', 'value1');
await db.put('key2', 'value2');
await db.put('key3', 'value3');
// Create a read stream
const stream = db.createReadStream();
stream.on('data', ({ key, value }) => {
console.log(`${key}: ${value}`);
});
stream.on('end', () => {
console.log('Stream ended');
});
leveldown is a LevelDB backend for the LevelUP library. Unlike memdown, which stores data in memory, leveldown stores data on disk using Google's LevelDB. This makes it suitable for applications that require persistent storage.
rocksdb is a backend for the LevelUP library that uses Facebook's RocksDB, a high-performance, persistent key-value store. It offers better performance and more features compared to LevelDB, making it suitable for high-throughput applications.
sqlite3 is a backend for the LevelUP library that uses SQLite, a self-contained, serverless, and zero-configuration SQL database engine. It provides a more feature-rich and flexible storage solution compared to memdown, with support for complex queries and transactions.
An 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 MemDOWN = require('memdown')
, levelup = require('levelup')
, factory = function (location) { return new MemDOWN(location) }
, db = levelup('/does/not/matter', { db: factory })
db.put('name', 'Yuri Irsenovich Kim')
db.put('dob', '16 February 1941')
db.put('spouse', 'Kim Young-sook')
db.put('occupation', 'Clown')
db.readStream()
.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 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.
FAQs
An drop-in replacement for LevelDOWN that works in memory only
The npm package memdown receives a total of 155,725 weekly downloads. As such, memdown popularity was classified as popular.
We found that memdown demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.