
Security News
GitHub Actions Checkout Now Blocks Risky pull_request_target Checkouts
GitHub Actions checkout now blocks risky pull_request_target checkouts by default to help prevent pwn request supply chain attacks.
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 20 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.
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
GitHub Actions checkout now blocks risky pull_request_target checkouts by default to help prevent pwn request supply chain attacks.

Product
Socket now supports Custom Roles and Repository Access Permissions so organizations can control who can access specific repositories and actions.

Product
Socket MCP now lets AI assistants review org alerts, investigate threats using the Socket threat feed, and inspect package files in addition to dependency scoring.