npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@diyst/vcache

v1.0.1

Published

VCache is a simple cache library that provides in-memory and LMDB-based caching functionalities for Node.js applications.

Downloads

6

Readme

VCache - In-memory and LMDB Cache

Overview

VCache is a simple cache library that provides in-memory and LMDB-based caching functionalities for Node.js applications. The cache can store both small and large data with optional expiration times for cached items. The library offers easy-to-use methods for setting, getting, checking existence, and deleting cached items.

Installation

npm i @diyst/vcache

Usage

To begin using VCache, import the library and create an instance of the VCache class:

import { VCache, CacheTypes } from 'vcache';

const cache = new VCache();

Caching Data

You can cache data using the set method:

// Cache a small item without expiration time
cache.set('smallItem', 'This is a small cached item.', CacheTypes.small);

// Cache a large item with an expiration time of 1 hour (in milliseconds)
cache.set('largeItem', 'This is a large cached item with expiration.', CacheTypes.large, 3600000);

Retrieving Cached Data

Retrieve cached data using the get method:

const smallItem = cache.get('smallItem');
const largeItem = cache.get('largeItem');

console.log(smallItem); // Output: 'This is a small cached item.'
console.log(largeItem); // Output: 'This is a large cached item with expiration.'

Checking Existence

You can check if a key exists in the cache using the exist method:

if (cache.exist('smallItem')) {
  // The key exists in the cache
} else {
  // The key does not exist in the cache
}

Deleting Cached Data

To delete an item from the cache, use the delete method:

cache.delete('smallItem'); // Deletes the 'smallItem' from the cache, if it exists.

Closing the Connection

When you're done using the cache, make sure to close the connection to release resources:

cache.closeConnection();

Conclusion

VCache is a versatile caching library that allows you to store small and large data efficiently in-memory and using LMDB storage. With optional expiration times, it ensures your cached data stays up to date while minimizing memory usage. Use VCache to boost the performance of your Node.js applications by caching frequently accessed data.