shahradelahi / storage-box

πŸ’Ύ A Memory-based key-value storage system for JavaScript.

Home Page:https://www.npmjs.com/package/storage-box

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

StorageBox
CI npm npm bundle size MIT

storage-box is a JavaScript library designed for the purpose of storing data in various structures across multiple storage systems. The primary goal of this library is to offer a straightforward and effective method for data storage.

πŸ‘€ Features

  • Simple API
  • Support for Node.js, Bun and the browser
  • Support for multiple storage types (Memory, File, Browser-storage, etc.)
  • Multiple data structures (Literals, Hashes, Lists, etc.)
  • Time-based key expiration

βš™οΈ Installation

npm i storage-box

πŸ“– Usage

import { Client } from 'storage-box';

const client = new Client();

client.setex('key', 'value', 2);

console.log(client.get('key')); // value

// time to live in milliseconds
console.log(client.ttl('key', true)); // 2000

// after 3 seconds
setTimeout(() => {
  console.log(client.get('key')); // undefined
}, 3e3);

πŸ“¦ Storage Types

  • Memory (Docs) (default)
  • File-based (Fs) (Docs)
  • Local/Session Storage (Docs)

πŸ“š Documentation

For all configuration options, please see the API docs.

🀝 Contributing

You can contribute to this project by opening an issue or a pull request on GitHub. Feel free to contribute, we care about your ideas and suggestions.

Project Stats

Alt

License

MIT Β© Shahrad Elahi

About

πŸ’Ύ A Memory-based key-value storage system for JavaScript.

https://www.npmjs.com/package/storage-box

License:MIT License


Languages

Language:TypeScript 100.0%