JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 28
  • Score
    100M100P100Q57558F
  • License MIT

A memory-based key–value storage for javascript.

Package Exports

  • storage-box
  • storage-box/browser
  • storage-box/node

Readme

storage-box

CI npm npm bundle size MIT

Storing data in various structures across multiple storage systems.

Notable Features

  • Easy to use API
  • Support for Node.js, Bun and the browser
  • Support for multiple storage types (memory, file, local 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();

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

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

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

// after 3 seconds
setTimeout(async () => {
  console.log(await 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.

License

MIT Β© Shahrad Elahi