Some checks failed
🚀 Build & Deploy Image / Determine Build Necessity (push) Failing after 10m14s
🚀 Build & Deploy Image / Build Runtime Base Image (push) Has been skipped
🚀 Build & Deploy Image / Build Docker Image (push) Has been skipped
🚀 Build & Deploy Image / Run Tests & Quality Checks (push) Has been skipped
🚀 Build & Deploy Image / Auto-deploy to Staging (push) Has been skipped
🚀 Build & Deploy Image / Auto-deploy to Production (push) Has been skipped
Security Vulnerability Scan / Check for Dependency Changes (push) Failing after 11m25s
Security Vulnerability Scan / Composer Security Audit (push) Has been cancelled
- Remove middleware reference from Gitea Traefik labels (caused routing issues) - Optimize Gitea connection pool settings (MAX_IDLE_CONNS=30, authentication_timeout=180s) - Add explicit service reference in Traefik labels - Fix intermittent 504 timeouts by improving PostgreSQL connection handling Fixes Gitea unreachability via git.michaelschiemer.de
97 lines
2.5 KiB
JavaScript
97 lines
2.5 KiB
JavaScript
/**
|
|
* Cache Manager Module
|
|
*
|
|
* Provides intelligent caching for API responses and computed values.
|
|
*
|
|
* Usage:
|
|
* - Add data-module="cache-manager" to enable global cache manager
|
|
* - Or import and use directly: import { CacheManager } from './modules/cache-manager/index.js'
|
|
*
|
|
* Features:
|
|
* - Memory cache
|
|
* - IndexedDB cache
|
|
* - Cache invalidation strategies
|
|
* - Cache warming
|
|
* - Cache analytics
|
|
* - Integration with RequestDeduplicator
|
|
*/
|
|
|
|
import { Logger } from '../../core/logger.js';
|
|
import { CacheManager, CacheStrategy } from './CacheManager.js';
|
|
import { getStrategyForUseCase } from './CacheStrategy.js';
|
|
|
|
const CacheManagerModule = {
|
|
name: 'cache-manager',
|
|
cacheManager: null,
|
|
|
|
init(config = {}, state = null) {
|
|
Logger.info('[CacheManagerModule] Module initialized');
|
|
|
|
// Create cache manager
|
|
this.cacheManager = CacheManager.create(config);
|
|
|
|
// Expose globally for easy access
|
|
if (typeof window !== 'undefined') {
|
|
window.CacheManager = this.cacheManager;
|
|
window.CacheStrategy = CacheStrategy;
|
|
}
|
|
|
|
return this;
|
|
},
|
|
|
|
/**
|
|
* Get cache manager instance
|
|
*/
|
|
getCacheManager() {
|
|
return this.cacheManager || CacheManager.create();
|
|
},
|
|
|
|
/**
|
|
* Get value from cache
|
|
*/
|
|
async get(key, options = {}) {
|
|
const cache = this.getCacheManager();
|
|
return await cache.get(key, options);
|
|
},
|
|
|
|
/**
|
|
* Set value in cache
|
|
*/
|
|
async set(key, value, options = {}) {
|
|
const cache = this.getCacheManager();
|
|
return await cache.set(key, value, options);
|
|
},
|
|
|
|
/**
|
|
* Get or compute value
|
|
*/
|
|
async getOrSet(key, computeFn, options = {}) {
|
|
const cache = this.getCacheManager();
|
|
return await cache.getOrSet(key, computeFn, options);
|
|
},
|
|
|
|
destroy() {
|
|
if (this.cacheManager) {
|
|
this.cacheManager.destroy();
|
|
this.cacheManager = null;
|
|
}
|
|
|
|
if (typeof window !== 'undefined') {
|
|
delete window.CacheManager;
|
|
delete window.CacheStrategy;
|
|
}
|
|
|
|
Logger.info('[CacheManagerModule] Module destroyed');
|
|
}
|
|
};
|
|
|
|
// Export for direct usage
|
|
export { CacheManager, CacheStrategy, getStrategyForUseCase };
|
|
|
|
// Export as default for module system
|
|
export default CacheManagerModule;
|
|
|
|
// Export init function for module system
|
|
export const init = CacheManagerModule.init.bind(CacheManagerModule);
|
|
|