https://github.com/darky/ttl-counter
TTL counter
https://github.com/darky/ttl-counter
counter ttl
Last synced: 5 months ago
JSON representation
TTL counter
- Host: GitHub
- URL: https://github.com/darky/ttl-counter
- Owner: darky
- Created: 2019-09-05T20:02:25.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2024-06-16T14:22:05.000Z (almost 2 years ago)
- Last Synced: 2025-03-29T13:55:26.246Z (about 1 year ago)
- Topics: counter, ttl
- Language: TypeScript
- Size: 635 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 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
```typescript
import { TTLCounter } from 'ttl-counter';
const ttlCounter = new TTLCounter({
ttl: 60 * 1000 // TTL for specific counter,
countForCb: 50 // 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');
```