Giter VIP home page Giter VIP logo

hapi-cache-stats's Introduction

@jameswragg/hapi-cache-stats

Cache insights for Hapi.js servers with Catbox cache policies

Installation

npm i @jameswragg/hapi-cache-stats

Register the plugin as (one of) the first plugins on the server to ensure policies are caught.

const Hapi = require('@hapi/hapi');
const HapiCacheStats = require('@jameswragg/hapi-cache-stats');

(async () => {
  const server = Hapi.server({ port: 3000 });

  await server.register({
    plugin: HapiCacheStats,
    options: {
      // options here
    },
  });

  // app code here - using Catbox caches

  await server.start();

  console.log(`Start adding at ${server.info.uri}`);
})();

Then visit http://localhost:3000/cache-stats for live, real-time stats on all registered cache policies & method stats.

Main policy stats view screenshot of policy stats

Seeing what methods use the cache policy & their individual stats screenshot showing the method stats

Plugin options

  • base - route to mount the UI on, default: '/cache-stats'
  • snapshot - object with the following settings regarding snapshots:
    • interval - every X seconds, default: 5
    • retention: how many snapshots to retain, default: 60
  • socketIo - socket.io server options, default: { cors: { origin: '*' } }

Development

To contribute to the project:

  1. Clone the repo
  2. npm install
  3. npm run dev - will file up an example server with policies, caches and a Vite server to host the frontend

Then append ?dev to the url e.g. http://localhost:3000/cache-stats?dev. This will load the Vue front-end via the Vite server instead of built assets, supporting HMR on change etc.

hapi-cache-stats's People

Contributors

jameswragg avatar

Stargazers

Alex Vechkanov  avatar Kima avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.