Enable Discovery debug logging for production troubleshooting
- Add DISCOVERY_LOG_LEVEL=debug - Add DISCOVERY_SHOW_PROGRESS=true - Temporary changes for debugging InitializerProcessor fixes on production
This commit is contained in:
@@ -1,34 +1,61 @@
|
||||
/**
|
||||
* Simple cache implementation with TTL support
|
||||
*/
|
||||
export class SimpleCache {
|
||||
constructor(maxSize = 20, ttl = 60000) {
|
||||
constructor(maxSize = 20, defaultTTL = 60000) {
|
||||
this.cache = new Map();
|
||||
this.maxSize = maxSize;
|
||||
this.ttl = ttl;
|
||||
this.ttl = defaultTTL;
|
||||
}
|
||||
|
||||
get(key) {
|
||||
const cached = this.cache.get(key);
|
||||
if (!cached) return null;
|
||||
if (Date.now() - cached.timestamp > this.ttl) {
|
||||
const entry = this.cache.get(key);
|
||||
if (!entry) return null;
|
||||
|
||||
// Check if entry is expired
|
||||
if (Date.now() - entry.timestamp > this.ttl) {
|
||||
this.cache.delete(key);
|
||||
return null;
|
||||
}
|
||||
return cached.data;
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
set(key, data) {
|
||||
set(key, value) {
|
||||
// Remove oldest entries if cache is full
|
||||
if (this.cache.size >= this.maxSize) {
|
||||
// Entferne das älteste Element
|
||||
const oldest = [...this.cache.entries()].sort((a, b) => a[1].timestamp - b[1].timestamp)[0][0];
|
||||
this.cache.delete(oldest);
|
||||
const oldestKey = [...this.cache.entries()]
|
||||
.sort((a, b) => a[1].timestamp - b[1].timestamp)[0][0];
|
||||
this.cache.delete(oldestKey);
|
||||
}
|
||||
this.cache.set(key, { data, timestamp: Date.now() });
|
||||
|
||||
this.cache.set(key, value);
|
||||
}
|
||||
|
||||
has(key) {
|
||||
return this.get(key) !== null;
|
||||
const entry = this.get(key);
|
||||
return entry !== null;
|
||||
}
|
||||
|
||||
delete(key) {
|
||||
return this.cache.delete(key);
|
||||
}
|
||||
|
||||
clear() {
|
||||
this.cache.clear();
|
||||
}
|
||||
}
|
||||
|
||||
size() {
|
||||
return this.cache.size;
|
||||
}
|
||||
|
||||
// Clean up expired entries
|
||||
cleanup() {
|
||||
const now = Date.now();
|
||||
for (const [key, value] of this.cache.entries()) {
|
||||
if (now - value.timestamp > this.ttl) {
|
||||
this.cache.delete(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user