Socket
Socket
Sign inDemoInstall

keyv

Package Overview
Dependencies
0
Maintainers
1
Versions
52
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    keyv

Simple key/value store with support for multiple backends


Version published
Maintainers
1
Install size
7.57 kB
Created

Package description

What is keyv?

The keyv npm package is a simple key-value storage with support for multiple backends. It is designed to be a straightforward solution for key-value storage across different systems and protocols. It supports TTL based expiry, making it suitable for applications like caching and session storage.

What are keyv's main functionalities?

Simple Key-Value Storage

Store and retrieve data using simple key-value pairs.

{"const Keyv = require('keyv');
const keyv = new Keyv();
keyv.set('foo', 'bar').then(() => keyv.get('foo').then(value => console.log(value)));
// Logs: 'bar'"}

Namespaces

Use namespaces to avoid key collisions when sharing the same storage backend.

{"const Keyv = require('keyv');
const users = new Keyv('sqlite://path/to/database.sqlite', { namespace: 'users' });
const cache = new Keyv('sqlite://path/to/database.sqlite', { namespace: 'cache' });
// `users` and `cache` can share the same storage without key collisions."}

Support for Multiple Backends

Keyv can be used with various storage backends like Redis, MongoDB, SQLite, and more.

{"const Keyv = require('keyv');
const keyv = new Keyv('redis://user:pass@localhost:6379');
keyv.set('foo', 'bar').then(() => keyv.get('foo').then(value => console.log(value)));
// This will use Redis as the storage backend."}

TTL (Time to Live)

Automatically expire keys after a certain period of time.

{"const Keyv = require('keyv');
const keyv = new Keyv({ ttl: 10000 });
keyv.set('foo', 'expires in 10 seconds', 10000).then(() => setTimeout(() => keyv.get('foo').then(value => console.log(value)), 15000));
// Logs: undefined, since the key has expired after 10 seconds."}

Other packages similar to keyv

Readme

Source

keyv

Simple key/value store with support for multiple backends

Build Status Coverage Status npm

Keyv is a simple key/value store with support for multiple backends via storage adapters. The Keyv API is basically just a promisified subset of the Map API. Keyv also has TTL support making it suitable as a cache or persistent storage.

Install

npm install --save keyv

License

MIT © Luke Childs

Keywords

FAQs

Last updated on 14 Jul 2017

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc