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

@seneca/entity-cache

v1.2.2

Published

Versioned caching plugin for seneca

Downloads

6

Readme

@seneca/entity-cache

Seneca plugin providing simple id-based distributed entity caching.

Npm Travis Coveralls Maintainability DeepScan grade dependencies Status Gitter

Node.js Seneca Versioned Caching module

This module is a plugin for the Seneca framework. It provides a data caching mechanism for Seneca data entities. Using this module will give your Seneca app a big performance boost.

The caching mechanism goes beyond simple key-based caching using memcached. In addition, a smaller "hot" cache is maintained within the Node process. Data entities are given transient version numbers, and these are used to synchronize the hot cache with memcached.

This plays nicely with multiple memcached instances, and allows Seneca apps to scale.

(See chapter 8 of my book for details, or read How key-based cache expiration works)

Quick example

This module works by wrapping the data entity actions (role:entity, cmd:save, ... etc). You just need to register it:

var seneca = require('seneca')()
seneca.use('memcached-cache')
seneca.use('entity-cache')

Then just use data entities as normal. Except things will be a lot faster.

Install

npm install seneca
npm install seneca-memcached-cache
npm install @seneca/entity-cache

You'll need the seneca-memcached-cache plugin as a dependency.

You'll also need memcached

Or... you can use redis: seneca-redis-cache.

Testing

The unit tests require a running memcached and redis.

Options

  • prefix : string "SE"
  • maxhot : number 1111
  • maxage : number 22222
  • expires : number 3600
  • hot : boolean true

Set plugin options when loading with:



seneca.use('entity-cache', { name: value, ... })

Note: foo.bar in the list above means { foo: { bar: ... } }

Action Patterns

Action Descriptions

« clear:hot-keys,plugin:entity-cache »

No description provided.


« get:stats,plugin:entity-cache »

No description provided.


« list:hot-keys,plugin:entity-cache »

No description provided.


Options

Here's how to set the options (the values shown are the defaults):

seneca.use('entity-cache',{
  prefix:  '@seneca/entity-cache',
  maxhot:  1111,
  expires: 3600
})

Where:

  • prefix: prefix string to namespace your cache (useful if your cache is used by other things)
  • maxhot: the maximum number of hot items to store in the running node process memory
  • expires: how long to store items (in seconds)

Test

cd test
mocha *.test.js --seneca.log.print

Also

cd test
memcached -vv
mongod --dbpath=db
node n1.js --seneca.log=type:plugin
node n2.js --seneca.log=type:plugin