MCPcopy Create free account
hub / github.com/avoidwork/tenso / createStoreWithExpiredEntries

Function createStoreWithExpiredEntries

benchmarks/rate-limiting.js:408–420  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

406
407 // Create rate store with expired entries
408 const createStoreWithExpiredEntries = size => {
409 const store = new Map();
410 const currentTime = Math.floor(Date.now() / 1000);
411
412 for (let i = 0; i < size; i++) {
413 store.set(`client-${i}`, {
414 remaining: Math.floor(Math.random() * 100),
415 reset: currentTime - Math.floor(Math.random() * 1000) // Some expired, some not
416 });
417 }
418
419 return store;
420 };
421
422 const cleanupExpiredEntries = store => {
423 const currentTime = Math.floor(Date.now() / 1000);

Callers 1

benchmarkRateCleanupFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected