ttl-counter
TypeScript icon, indicating that this package has built-in type declarations

1.0.3 • Public • Published

TTL counter

TTL counter allow you to define some counters with TTL expire. Also you can call callback, when some threshold of counter reached.

Example

import { TTLCounter } from 'ttl-counter';
 
const ttlCounter = new TTLCounter({
  ttl: 60 * 1000 // TTL for specific counter,
  countForCb50 // After 50 count per minute, callback called,
  cb (counterId) {
    // For example, many errors occured per minute, restart pod
    process.exit(1);
  }
});
 
// On error call
ttlCounter.count('error');

Readme

Keywords

Package Sidebar

Install

npm i ttl-counter

Weekly Downloads

24

Version

1.0.3

License

MIT

Unpacked Size

2.69 kB

Total Files

4

Last publish

Collaborators

  • darrrk