npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

memkvstore

v1.2.0

Published

MemKvStore is a key-value store class implemented in TypeScript. It supports a variety of advanced features, including time-to-live (TTL) for keys, secondary indexing, write-ahead logging (WAL), multi-node consensus, data partitioning, versioning and conf

Downloads

18

Readme

MemKVStore

Release MemKVStore

MemKVStore is a key-value store class implemented in TypeScript. It supports a variety of advanced features, including time-to-live (TTL) for keys, secondary indexing, write-ahead logging (WAL), multi-node consensus, data partitioning, data compression and encryption, versioning and conflict resolution, batch operations and atomic transactions, event sourcing and CQRS (Command Query Responsibility Segregation), snapshots, and partitioning.

Features

  • Basic key-value store operations: Get, set, and delete operations.
  • Time-to-live (TTL) for keys: Keys can be set to automatically expire after a certain amount of time.
  • Secondary indexing: Allows efficient lookups based on values.
  • Write-ahead logging (WAL): Changes are logged before they are applied, ensuring data integrity.
  • Multi-node consensus: Multiple nodes can agree on the state of the data.
  • Data partitioning: Data can be split across multiple nodes.
  • Versioning and conflict resolution: Multiple versions of a value can be stored, and conflicts between versions can be resolved.
  • Batch operations and atomic transactions: Multiple operations can be performed as a single atomic transaction.
  • Event sourcing and CQRS: Changes to the data are stored as a sequence of events, which can be replayed to reconstruct the current state.
  • Snapshots: The current state can be saved and restored later.
  • Partitioning: Data can be divided into partitions, which can be processed in parallel.
  • LRU eviction policy: When the store is full, the least recently used items are evicted.

Usage

You can use your own storage strategy that needs to implement StorageEngine, but you can also use the already packaged InMemoryStore module:

import { Store } from "memkvstore";

let store = new Store<any, any>();

That's it! You can now use the store instance as following:

await store.set("key", "value", tll?); // it will return true

await store.get("key"); // it will return { value: "value", version: 0 } (example)

await store.delete("key"); // it will return { status: true, keyDeleted: key }

await store.bulkSet(
    ["key1", "key2", "key3"],
    ["val1", "val2", "val3"]
); // it will return { status: true, keys: keys.length, values: values.length }

await store.bulkDelete(
    ["key1", "key2", "key3"]
); // it will return { status: true, keysDeleted: keys.length }

await store.resetSession(); // it will return undefined