A simple lock-and-release eventually-consistent DB to be consumed by multi-threaded applications in node.

Overview

worsen - a persistence store for quick prototyping

A simple lock-and-release eventually-consistent DB to be consumed by multi-threaded applications in node.

Installation

npm i worsen

npm version

About

  • The database constructed as a utility for quick consumption by nodejs prototypes. It is not intended to be used in production.

  • It has been tested for multiple concurrent writes and reads on 8 cores, but it is not guaranteed to be safe for production use.

  • It can be used for maintaining queues and other data structures that are not expected to be updated frequently.

  • The store will backup the cache to a file before every write. The backup file is named <store-name>.cache.db.

Known Issues

  • There might be a case where lockfile cleanup fails. This is handled if retries exceed a certain number. The store removes itself from locked state. This though clears the locked state might not be able to recover the data if the thread which was previous holding the lock crashed. This is a known issue and will be fixed in the next release. This case has been completely avoided by having a poll rate over 10_000ms for our tests.

Usage:

const store = new PersistentStore<boolean>( // generic over T
  'persistent-store-test'// name for logs and file in db_dir
  {
    // boolean-> defaults to process.env.DEBUG_PERSISTENCE === 'true'
    is_debug: false 

    // optional-> defaults to  join(__dirname, 'db')
    db_dir: "." 
    }
)
store.init(
  // polling interval in ms
  5_000, 
  // optional array of seed data
  // type-> { uid:string, data:T }[] 
  // where T is generic over PersistentStore<T>
  // only updates the db if the db is empty
  [
	{
		uid: 'AppInit',
		data: true,
	},
])
// read from store - synchronous read.
const returned_value:bool = store.read('AppInit')
// write from store
await store.write('AppErrors', false)
// get the current state copy. 
// Copies memory.
// Can cause potential leaks if not
// used correctly. (like in loops)
await store.get_hashmap_state()

CLI

npm i -g worsen
  • Default Init

> init [db_dir] [name] # defaults to init ./db_dir worsen
worsen >
  • Init

> init ./db_dir data # change db location and/or name
data > 
  • List

worsen > list
{
  "key1": "value1",
  "key2": "value2",
  "key3": "value3",
}
  • Keys

worsen > keys # list keys of db after init
key1
key2
key3
  • Get Value

worsen > get key1 # get key value
value1
worsen > exit
You might also like...

A pointer lock movement manager for customizing your own creative UI.

A pointer lock movement manager for customizing your own creative UI.

Pointer Lock Movement A pointer lock movement manager for customizing your own creative UI. Inspired by Figma's number input element: Dragging on an i

Nov 4, 2022

A refined tool for exploring open-source projects on GitHub with a file tree, rich Markdown and image previews, multi-pane multi-tab layouts and first-class support for Ink syntax highlighting.

A refined tool for exploring open-source projects on GitHub with a file tree, rich Markdown and image previews, multi-pane multi-tab layouts and first-class support for Ink syntax highlighting.

Ink codebase browser, "Kin" 🔍 The Ink codebase browser is a tool to explore open-source code on GitHub, especially my side projects written in the In

Oct 30, 2022

Semantic Release plugin to create and publish NuGet packages.

semantic-release-nuget semantic-release plugin to create and publish a NuGet package. Step Description verifyConditions Verify the presence of the NUG

Jan 2, 2023

Minimalistic, opinionated, and predictable release automation tool.

Minimalistic, opinionated, and predictable release automation tool.

Release Minimalistic, opinionated, and predictable release automation tool. General idea Think Prettier but for automated releases: minimalistic, opin

Dec 18, 2022

Google Chrome release and version info as JSON (self updating)

chrome-versions Self updating repository to store Google Chrome release and version info as JSON. Windows macOS Linux Android TL;DR Use a CDN to fetch

Dec 15, 2022

Klecks is the official open-source release of the community-funded online painting app Kleki.

Klecks is the official open-source release of the community-funded online painting app Kleki.

Klecks (German for "splash of color", pronounced "clex") is the official open-source release of the community-funded online painting app Kleki. Klecks

Dec 27, 2022

The Blitz.js Recipe for installing @semantic-release/github.

semantic-release-github The Blitz.js Recipe for installing @semantic-release/github. blitz install custom-recipes/semantic-release-github -y More info

Apr 9, 2022

🚀 A GitHub action to publish a new release of the repository

Create a JavaScript Action using TypeScript Use this template to bootstrap the creation of a TypeScript action. 🚀 This template includes compilation

Nov 1, 2022

Crypto Basket - Free Blockchain Press Release

ADD YOUR CONTENT Upload all files to IPFS All non-IPFS links should be inside LINKS Sections Use markdown syntax How to add content to CryptoBasket ?

Dec 15, 2022
Releases(v0.0.4-alpha.4)
Owner
Aniket Biprojit Chowdhury
Aniket Biprojit Chowdhury
Detect npm packages by author name in your package-lock.json or yarn.lock.

detect-package-by-author Detect npm packages by author name in your package-lock.json or yarn.lock. Install Install with npm: # Not Yet Publish # npm

azu 2 Jan 11, 2022
GitHub Action to create a release PR using cargo-release

Action: (Cargo) release-pr A GitHub Action for creating "Release PRs" for Cargo projects. Purpose This action uses cargo-release to perform a release

null 18 Nov 16, 2022
Eventually* Everything you'll need for successful feature flagging

remix-flags Eventually* Everything you'll need for successful feature flagging What's inside? This repo uses npm as a package manager. It includes the

Jacob Ebey 16 Jun 10, 2022
A leaderboard website that displays scores submitted by different players. It was developed with Javascript, HTML, CSS and the Leaderboard API service was consumed.

LeaderBoard App Description The leaderboard website displays scores submitted by different players. It also allows you to submit your score. All data

Bright Kweku Ahiadeke 6 Jul 25, 2022
A full-stack social media application where users can post and share their coding projects, adding friends, and joining the discussion in threaded comments on project posts.

CodeFlow Description CodeFlow is a social media application where users can post and share their coding projects with others. By logging in or signing

Chris Nohilly 4 Dec 8, 2022
Generate smooth, consistent and always-sexy box-shadows, no matter the size, ideal for design token generation.

smooth-shadow Generate smooth, consistent and always-sexy box-shadows, no matter the size, ideal for design token generation. Demo As Tobias already p

Thomas Strobl 4 Oct 15, 2022
Vesting contract with multiple beneficiaries, tokens, and lock schedules.

⚠️ This code has not been audited, use at your own risk Vesting Contract This contract handles the vesting of ERC20 tokens for multiple beneficiaries.

DeFi Wonderland 5 Mar 14, 2022
Provides Lock and RwLock synchronization primitives.

Lock Provides Lock and RWLock (read write lock) synchronization primitives for protecting in-memory state across multiple tasks and/or microtasks. Ins

Rocicorp 4 Apr 27, 2022
Deduplication tool for pnpm-lock.yaml files

pnpm-deduplicate Remove duplicate dependencies from pnpm-lock.yaml. This project is simple and not have many features. I see it as a temporary solutio

null 62 Jan 3, 2023
Deno's first lightweight, secure distributed lock manager utilizing the Redlock algorithm

Deno-Redlock Description This is an implementation of the Redlock algorithm in Deno. It is a secure, lightweight solution to control resource access i

OSLabs Beta 223 Dec 31, 2022