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

bkjs-cache

v0.5.4

Published

Cache and LRU support for node.js and backendjs

Downloads

19

Readme

Cache module for node and backendjs

Usage

  • Generic cache outside of V8 heap, implements named sets of caches, name refers to a separate named cache with its own set of keys:
    • put(name, key, value) - save a key value pair in the named cache
    • incr(name, key, value) - increment a key value, non existent keys are assumed to be 0
    • get(name, key) - return value for a key
    • del(name, key) - delete a key
    • exists(name, key) - returns true if a key exists
    • keys(name) - return a list of all keys in the named cache
    • clear(name, ttl) - delete all keys, if ttl is greater than 0 then it must be a number of seconds the cache will be alive till it expires, all subsequent items put in the cache will live until it expires automatically
    • names() - returs all existing named caches
    • size(name) - returns size of a cache
    • each(name, callback) - call a callback for each key
    • begin(name) - returns first key
    • next(name) - returns next key or undefined when reached the end
  • LRU internal cache outside of V8 heap:
    • lruInit(max) - init LRU cache with max number of keys, this is in-memory cache which evicts older keys
    • lruStats() - return statistics about the LRU cache
    • lruSize() - return size of the current LRU cache
    • lruCount() - number of keys in the LRU cache
    • lruPut(name, val [, expire]) - set/replace value by name, expire is the time in the future when this key becomes invalid
    • lruGet(name [, now]) - return value by name, if now is given in ms then a key with ttl below this timestamp will be considered invalid and deleted even if the expiration never been set before
    • lruIncr(name, val [, expire]) - increase value by given number, non existent items assumed to be 0
    • lruDel(name) - delete by name
    • lruKeys([pattern] [,level]) - return all cache key names, if pattern is given match all keys beginning with it, if details is 1 then return an array with keys and expiration, if details is 2 then return an array with item key, value and expiration
    • lruClear() - clear LRU cache
    • lruClean() - remove the oldest item from the cache
    • lruFront() - return the oldest key

Author

Vlad Seryakov