organ-ai-zer
Version:
AI-powered file organizer CLI tool
66 lines โข 3.25 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.cache = cache;
const suggestion_cache_1 = require("../services/suggestion-cache");
const project_detection_cache_1 = require("../services/project-detection-cache");
const pattern_cache_1 = require("../services/pattern-cache");
async function cache(action, options) {
try {
// Get all cache instances using the unified BaseCache architecture
const caches = [
{ name: 'Suggestion Cache', icon: '๐๏ธ', instance: suggestion_cache_1.SuggestionCache.getInstance() },
{ name: 'Project Detection Cache', icon: '๐๏ธ', instance: project_detection_cache_1.ProjectDetectionCache.getInstance() },
{ name: 'Pattern Cache', icon: '๐', instance: pattern_cache_1.PatternCache.getInstance() }
];
switch (action) {
case 'clear':
if (options.directory) {
// Clear cache for specific directory across all cache types
for (const cache of caches) {
await cache.instance.clearCache(options.directory);
}
console.log(`๐๏ธ Cleared cache for directory: ${options.directory}`);
}
else {
// Clear all caches
for (const cache of caches) {
await cache.instance.clearCache();
}
console.log('๐๏ธ Cleared all caches');
}
break;
case 'clean':
// Clean expired entries from all caches
for (const cache of caches) {
await cache.instance.cleanExpiredCache();
}
console.log('๐งน Cleaned expired cache entries from all caches');
break;
case 'stats':
console.log('๐ Cache Statistics:');
console.log('');
for (const cache of caches) {
const stats = cache.instance.getCacheStats();
console.log(`${cache.icon} ${cache.name}:`);
console.log(` Memory entries: ${stats.memoryEntries}`);
console.log(` TTL: ${Math.round(stats.ttlMs / 1000 / 60)} minutes`);
console.log(` Cache directory: ${stats.diskCacheDir}`);
console.log('');
}
break;
default:
console.error('โ Unknown cache action. Available actions: clear, clean, stats');
console.log('Usage:');
console.log(' organ-ai-zer cache clear # Clear all caches');
console.log(' organ-ai-zer cache clear -d ~/Photos # Clear cache for specific directory');
console.log(' organ-ai-zer cache clean # Remove expired entries');
console.log(' organ-ai-zer cache stats # Show cache statistics');
process.exit(1);
}
}
catch (error) {
console.error('โ Cache operation failed:', error);
process.exit(1);
}
}
//# sourceMappingURL=cache.js.map