fastkv
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

FastKV

FastKV is a key-value store which offers the following features:

  • Supports temporary in-memory storage 🕒
  • Supports persistent storage with JSON files 📁
  • Lightweight with no dependencies ⚡

Installation

Get FastKV via npm using your favourite package manager:

npm install fastkv
# or
yarn add fastkv
# or
pnpm add fastkv

Example

import { KV } from 'fastkv';

// For TypeScript users, the KV supports generics:
// const example = new KV<string>();
// Or: example.get<string>('my-key-name');

const kv = new KV('./db.json'); // Save the data. Path resolves with process.cwd()
const cache = new KV('::memory::'); // Keep the data in the system's memory.

// Set data
kv.set('userSettings', { theme: 'dark' }); // -> KV

// Retreive data by a key
kv.get('userSettings'); // -> { theme: 'dark' }

// Retreive all data
kv.all(); // -> [{ key: 'userSettings', value: { theme: 'dark' } }]

// Clear the store
kv.clear(); // -> KV

Readme

Keywords

Package Sidebar

Install

npm i fastkv

Weekly Downloads

0

Version

1.0.0

License

MIT

Unpacked Size

5.73 kB

Total Files

6

Last publish

Collaborators

  • wlix