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

cachemon

v1.0.7

Published

A utiltiy for implementing redis based data caching and querying

Downloads

3

Readme

Modules

Classes

Constants

Functions

Cachemon

exports.initialize ⇒ Promise.<any>

Kind: global constant of Cachemon

| Param | | --- | | config |

exports.resource ⇒ CacheMonClient

Kind: global constant of Cachemon

| Param | | --- | | clientConfig |

Example

const cnrCache = new CacheMonClient({
        name: 'DATA',
        executeCronJob: false,
        cronPeriod: '0 * * * * *',
        cronExecutorFn: (done) => {
            i++;
            console.log('Running');
            request({
                url: 'https://api.github.com/users/rajatady/repos?per_page=10',
                headers: {
                    'User-Agent': 'request'
                }
            }, (err, response, body) => {
                if (err) {
                    done();
                } else {
                    cnrCache.updateResourcePool(body)
                        .then(res => {
                            console.log('Done');
                        })
                        .catch(err => {
                            console.log(err);
                        })
                }
            });
        },
        requestMethod: 'GET',
        urlDomain: '/data'
    });


 cnrCache.on('updated', (data) => {
        console.log('Updated');
    });

 export default resource(cnrCache);

exports.hasKey ⇒ ⏏

Kind: global constant of Cachemon
Returns: Promise

| Param | Type | | --- | --- | | url | | | cacheModel | CacheMonClient |

exports.cacheMiddleware ⇒ function

Kind: global constant of Cachemon

| Param | Type | | --- | --- | | cacheModel | CacheMonClient |

exports.getResource ⇒ *

Kind: global constant of Cachemon

| Param | | --- | | resourceName |

generateHash(str) ⇒ * | PromiseLike.<ArrayBuffer>

Kind: global method of Cachemon

| Param | | --- | | str |

CacheMonClient ⇐ EventEmitter

Kind: global class
Extends: EventEmitter

new CacheMonClient(options)

| Param | Type | Default | Description | | --- | --- | --- | --- | | options | Object | | The options for the Cachemon Client | | options.name | String | | The name of the client for which resources have to be scoped | | [options.allowFiltering] | String | | Whether the domain should allow data filtering (Planned) | | [options.urlDomain] | String | | The url domain registered with express. To be used for advanced caching (Planned) | | [options.requestMethod] | String | GET | The HTTP request method for the url domain (Planned) | | [options.cronPeriod] | String | | The cron period in a standard glob format. Refer to https://www.npmjs.com/package/node-cron for more | | [options.purgeCronPeriod] | String | | The cron period for the purge function in a standard glob format. Refer to https://www.npmjs.com/package/node-cron for more | | [options.executeCronJob] | Boolean | | Should the cron function be executed | | [options.cronExecutorFn] | function | | The function to be executed whenever the cron job runs | | [options.updaterFn] | function | | The function to be executed whenever request is served from cache | | [options.purgeFn] | function | | The function to be executed whenever cron time for purge is reached | | [options.shouldRunUpdater] | Boolean | false | Should the updater function run | | [options.shouldRunPurge] | Boolean | false | Should the purge function run | | [options.maintainUrls] | Boolean | false | Should a new data pool be created based on request url | | [options.preSendCallback] | function | | The function which gets the control once the data from cache is evaluated and is ready to be sent |

setData(key, value) ⇒ Promise.<any>

Set some data in the resource. The key will be prefixed with the resource name specified earlier

Kind: global function

| Param | Type | Description | | --- | --- | --- | | key | String | The key to be put in the cache | | value | String | The data to be saved |

getData(key) ⇒ Promise.<any>

Get some data from the resource. The key will be prefixed with the resource name specified earlier

Kind: global function

| Param | Type | Description | | --- | --- | --- | | key | String | The key to fetch from the cache |

setResourcePool(resourcePoolData) ⇒ Promise.<any>

Sets the data in the resource pool

Kind: global function

| Param | Type | Description | | --- | --- | --- | | resourcePoolData | String | Set the data in the resource pool |

getResourcePool() ⇒ Promise.<any>

Get the data from the resource pool

Kind: global function

appendToResourcePool(appendData) ⇒ Promise.<any>

Kind: global function

| Param | | --- | | appendData |

updateResourcePool(updateData, preventEmit) ⇒ Promise.<any>

Kind: global function

| Param | Type | | --- | --- | | updateData | | | preventEmit | Boolean |

runCronJob()

Kind: global function

saveMeta(key, value) ⇒ Promise.<any>

Set the meta info in the cache

Kind: global function

| Param | | --- | | key | | value |

getMeta() ⇒ Promise.<any>

Get the meta info saved in the cache

Kind: global function

invalidateResourcePool() ⇒ Promise.<any>

Kind: global function

runUdaterFunction()

Manually run the updater function

Kind: global function