import {
LRUCache,
memoize,
memoizeAsync,
getPatternCacheMetrics,
} from '@dotsetlabs/cli';
// Create an LRU cache
const cache = new LRUCache<string, RegExp>({ maxSize: 1000 });
cache.set('aws-key', /AKIA[A-Z0-9]{16}/g);
// Memoize expensive functions
const parsePattern = memoize((pattern: string) => {
return new RegExp(pattern, 'gi');
});
// Memoize async functions
const fetchSecrets = memoizeAsync(async (key: string) => {
return await secretsManager.getValue(key);
}, { ttlMs: 60000 });
// Check cache performance
const metrics = getPatternCacheMetrics();
console.log(`Cache hit rate: ${metrics.hitRate}%`);