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

appolo-cache

v8.0.0

Published

In memory lru cache

Downloads

1,168

Readme

Appolo lru cache

Build Status Dependencies status NPM version npm Downloads Known Vulnerabilities

Fast and simple lru cache for node.js written in typescript.

The cache will remove the oldest used item when reached max capacity

Installation:

npm install appolo-cache --save

Usage:

import {Cache} from "appolo-cache";
 
//max items in cache is 5 and all the items will expire after 1 second
 let cache  = new Cache<string,string>({maxSize:5,maxAge:1000})

cache.set("test", "value")
cache.get("test") // "value"

cache.set("test2", "value",2000) // will expire after 2 secs
cache.reset();    // empty the cache

Options

  • maxSize - The maximum size of the cache, default 1000
  • maxAge optional set maximum age in ms of all cache items. if set getting expired item it will return null

API

set(key, value, [maxAge])

Set the value of the key and mark the key as most recently used. if maxAge is passed the item will expire after maxAge ms.

get(key)

Return the value of the key. If the key is not found or expired return null. mark the key as most recently used.

peek(key)

return the value of the key If the key is not found or expired return null. will not update recently used.

del(key)

Deletes a key out of the cache.

reset()

Reset the cache and delete all items.

has(key)

Return true if a key is in the cache, will not update recently used

forEach(function(value,key,cache), [this])

Loop over the cache items

keys()

Return an array of the keys in the cache.

values()

Return an array of the values in the cache.

size

Return the size of the cache.

prune()

Delete all expired items.

pop()

Remove and return the least recently used

maxAge

getter setter cache max age.

maxSize

getter setter cache max size.

maxSize

getter setter cache max size.

hit(key)

Mark the key as most recently used.

ttl(key)

Get the ttl time left of the key item.

expire(key,maxAge)

Update the expire time of the key item.

License

MIT