
Security News
Happy Birthday, Shai-Hulud
It has been one year since Shai-Hulud made its first appearance on npm.
fs-key-value
Advanced tools
A simple key-value data store using only the filesystem. Uses POSIX file locking for safe operation in multi-process environments without the overhead of a separate database server.
get, put, delete)npm install fs-key-value
const FsKeyValue = require('fs-key-value');
const db = new FsKeyValue();
await db.openAsync('./mydb');
// Store a value
await db.putAsync('user:1', { name: 'Alice', age: 30 });
// Retrieve the value
const data = await db.getAsync('user:1');
console.log(data); // { name: 'Alice', age: 30 }
// Delete the value
await db.deleteAsync('user:1');
var FsKeyValue = require('fs-key-value');
var db = new FsKeyValue('./mydb', function (err, db) {
if (err) throw err;
// Store a value
db.put('user:1', { name: 'Alice', age: 30 }, function (err) {
if (err) throw err;
// Retrieve the value
db.get('user:1', function (err, data) {
if (err) throw err;
console.log(data); // { name: 'Alice', age: 30 }
// Delete the value
db.delete('user:1', function (err) {
if (err) throw err;
console.log('Deleted!');
});
});
});
});
new FsKeyValue([directory], [callback])Creates a new key-value store instance.
directory (string, optional): Path to the storage directorycallback (function, optional): Called with (err, db) when initialization completesdb.open(directory, callback)Initialize or reinitialize the store with a directory. Creates the directory if it doesn't exist.
directory (string): Path to the storage directorycallback (function): Called with (err, db) when completedb.get(key, callback)Retrieve a value by key.
key (string): The key to retrievecallback (function): Called with (err, value). Value is undefined if key doesn't exist.db.put(key, value, callback)Store a value. The value is serialized to JSON.
key (string): The key to storevalue (any): Any JSON-serializable valuecallback (function): Called with (err) when completedb.delete(key, callback)Delete a key from the store.
key (string): The key to deletecallback (function): Called with (err) when completeAll methods are also available as async/Promise versions:
db.openAsync(directory) → Promise<void>db.getAsync(key) → Promise<value | undefined>db.putAsync(key, value) → Promise<void>db.deleteAsync(key) → Promise<void>This example demonstrates safe concurrent access from multiple worker processes:
var cluster = require('cluster');
var FsKeyValue = require('fs-key-value');
if (cluster.isMaster) {
// Fork 8 worker processes
for (var i = 0; i < 8; i++) {
cluster.fork();
}
} else {
var id = cluster.worker.id % 2;
var mydb = new FsKeyValue('./mydb', function (err, db) {
if (err) {
return console.log(err);
}
db.put(
'hoopla' + id,
{ msg: 'ballyhoo ' + cluster.worker.id },
function (err) {
if (err) {
return console.log(cluster.worker.id + ' err ' + err);
}
db.get('hoopla' + id, function (err, data) {
if (err) {
return console.log(cluster.worker.id + ' err ' + err);
}
if (data != undefined) {
console.log(data.msg);
}
db.delete('hoopla' + id);
cluster.worker.kill();
});
}
);
});
}
fs-ext for POSIX file locking (flock).lock) coordinates operationsMIT
FAQs
Key value data store using the filesystem
The npm package fs-key-value receives a total of 7 weekly downloads. As such, fs-key-value popularity was classified as not popular.
We found that fs-key-value demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.

Security News
It has been one year since Shai-Hulud made its first appearance on npm.

Research
/Security News
Operators behind PolinRider used a compromised GitHub account to plant malware in four development versions of a Packagist package with 700,000+ downloads.

Security News
GitHub Actions now supports cache-mode, a least-privilege control on the Actions cache aimed at the cache poisoning technique behind recent compromises.