Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/shahradelahi/storage-box

๐Ÿ—„๏ธ A memory-based keyโ€“value storage for Javascript
https://github.com/shahradelahi/storage-box

browser database key-value nodejs storage

Last synced: about 1 month ago
JSON representation

๐Ÿ—„๏ธ A memory-based keyโ€“value storage for Javascript

Awesome Lists containing this project

README

        


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

```bash
npm i storage-box
```

## ๐Ÿ“– Usage

```typescript
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](docs/driver-memory.md)) (default)
- File-based (Fs) ([Docs](docs/driver-fs.md))
- Local/Session Storage ([Docs](docs/driver-browser.md))

## ๐Ÿ“š Documentation

For all configuration options, please see [the API docs](https://paka.dev/npm/storage-box/api).

## ๐Ÿค Contributing

You can contribute to this project by opening an issue or a pull request
on [GitHub](https://github.com/shahradelahi/storage-box). Feel free to contribute, we care about your ideas and
suggestions.

## Project Stats

![Alt](https://repobeats.axiom.co/api/embed/e1a9aca6e883cd81bba207c4edb9713c24796edd.svg 'Repobeats analytics image')

## License

[MIT](/LICENSE) ยฉ [Shahrad Elahi](https://github.com/shahradelahi)