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

mongoose-cache-ts

v1.1.7

Published

This module caches **mongoose** queries with **cache-manager** using an in-memory or Redis store.

Readme

Mongoose Cache Manager

This module caches mongoose queries with cache-manager using an in-memory or Redis store.

Like many ODM cache solutions, the cache can only be kept fresh if this module is used for both reads and writes. When something writes directly to MongoDB without using mongoose, there is no way for this module to know it needs to reload fresh data into the cache.

In the future I want to try to improve this cache layer by using entity-based caching instead of only query caching.

Installation

$ npm install mongoose-cache-ts
or
$ yarn add mongoose-cache-ts

Usage

import { startRedisConnection, stopRedisConnection } from "mongoose-cache-ts";

// patch mongoose with default options
startRedisConnection({
  host: "192.1.54.7", // host your redis
  port: 6379, // port redis
  time: 60, // time cache exist
  password: "P1A2S3S4W5O6R7K8", // nullable
});
// Call when exist your app.
stopRedisConnection();

Then later any find query will be cached for 60 seconds.

You can also enable/disable caching programatically by using the cache method directly from the query instance:

const UserCollection = new Schema({...});

UserCollection
    .find(condition)
    .cache()
    .then((err, docs) => {
        if (err) throw error;
        // do something with your database
    });

When you want to populate or more out of queries. you can use the cache method like:

UserCollection.find(condition)
  .populate({
    path: "profile",
    // and more condition
  })
  .cache({
    hashKey: {
      populate: "profile",
    },
  })
  .then((err, docs) => {
    if (err) throw error;
    // do something with your database
  });

When you update, create or delete you want to reset redis:

import { clearKey, clearAllKey } from 'mongoose-cache-ts';

clearKey: will delete a key with data save in memory
example:
delete root key in UserCollection caching in memory
clearKey(UserCollection.collection.name);

clear all key in memory:
clearAllKey();
source readme: https://github.com/englercj/mongoose-cache-manager/edit/master/README.md