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 🙏

© 2026 – Pkg Stats / Ryan Hefner

hivemind-app-cache

v1.0.8

Published

Caching layer for app backends based on the Akenza IoT Platform

Readme

Hivemind App Cache Module

This module caches requests to the Hivemind IoT Platform for faster response time and fewer API calls.

For an example of how to use this module, check out Hivemind App Backend.

Entities

The entities submodule caches GET requests to the API for config.entityCacheTimeout milliseconds (defaults to 4 minutes).

If the response produces a list, a byId map will be added which allows access to individual entities using their id.

platform.entities.getEnvId(session, cbk)

Returns the ID of the (first) environment accessible using session.apiKey.

  • session {Object}
    • apiKey {String} Key to access the platform API.
  • cbk(err, envId) {Function}
    • err {Any}
    • envId {String}

platform.entities.getEntity(session, path, cbk)

Returns the response to the API call GET /v1/environments/{session.envId}{path}.

  • session {Object}
    • apiKey {String}
    • envId {String}
  • path {String}
  • cbk(err, ans) {Function}
    • err {Any}
    • ans {Object}

platform.entities.getList(session, path, cbk)

Returns the data array from the response to the API call GET /v1/environments/{session.envId}{path}.

  • session {Object}
    • apiKey {String}
    • envId {String}
  • path {String}
  • cbk(err, ans) {Function}
    • err {Any}
    • ans {Object}

platform.entities.getSingle(session, path, id, cbk)

Returns the entity with the given id when path points to a list. This call can improve response time since it requests all entities at once instead of individually.

  • session {Object}
    • apiKey {String}
    • envId {String}
  • path {String}
  • id {String}
  • cbk(err, ans) {Function}
    • err {Any}
    • ans {Object}

Samples

Samples are cached indefinitely. If a cursor tries to access older (not yet cached) samples, they are added to the cache transparently. New samples are added to the cache using WebSockets.

new platform.SampleCursor(session, devId, topic)

Returns a cursor to iterate over samples.

  • session {Object}
    • apiKey {String}
    • envId {String}
  • devId {String}
  • topic {String}

SampleCursor.forEach(cbk, done)

Calls cbk for each sample, as long as the return value is true or there are no more samples available. And calls done after.

  • cbk(sample) {Function}
    • sample {Object}
      • id {String}
      • timestamp {Date}
      • data {Object}
  • done(err) {Function}
    • err {Any}

Events

platform.events.on('sampleInsert', cbk)

Emitted when a new sample is added to a sample cache.

  • cbk(event) {Function}
    • event {Object}
      • envId {String}
      • devId {String}
      • topic {String}
      • sample {Object}
        • id {String}
        • timestamp {Date}
        • data {Object}

platform.events.on('sampleInvalidate', cbk)

Emitted when sample caches are destroyed. This can happen when samples are deleted, or a communication error occurs.

If topic is null, the sample caches of all topics are invalidated. If both devId and topic are null, the sample caches of all devices in the environment are invalidated.

After a sampleInvalidate event, no more sampleInsert events will be emitted for the affected caches (since they no longer exist). Access samples over a cursor to create a new cache.

  • cbk(event) {Function}
    • event {Object}
      • envId {String}
      • devId {String}
      • topic {String}