UNPKG

organ-ai-zer

Version:

AI-powered file organizer CLI tool

66 lines โ€ข 3.25 kB
"use strict"; 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