forked from trent_larson/crowd-funder-for-time-pwa
chore: Comment out the unused caching utilities (so they're not mistakenly used).
This commit is contained in:
@@ -59,14 +59,14 @@ import {
|
||||
// TYPESCRIPT INTERFACES
|
||||
// =================================================
|
||||
|
||||
/**
|
||||
* Cache entry interface for storing data with TTL
|
||||
*/
|
||||
interface CacheEntry<T> {
|
||||
data: T;
|
||||
timestamp: number;
|
||||
ttl: number; // milliseconds
|
||||
}
|
||||
// /**
|
||||
// * Cache entry interface for storing data with TTL
|
||||
// */
|
||||
// interface CacheEntry<T> {
|
||||
// data: T;
|
||||
// timestamp: number;
|
||||
// ttl: number; // milliseconds
|
||||
// }
|
||||
|
||||
/**
|
||||
* Vue component interface that uses the PlatformServiceMixin
|
||||
@@ -79,21 +79,21 @@ interface VueComponentWithMixin {
|
||||
platformService(): PlatformService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Global cache store for mixin instances
|
||||
* Uses WeakMap to avoid memory leaks when components are destroyed
|
||||
*/
|
||||
const componentCaches = new WeakMap<
|
||||
VueComponentWithMixin,
|
||||
Map<string, CacheEntry<unknown>>
|
||||
>();
|
||||
|
||||
/**
|
||||
* Cache configuration constants
|
||||
*/
|
||||
const CACHE_DEFAULTS = {
|
||||
default: 15000, // 15 seconds default TTL
|
||||
} as const;
|
||||
// /**
|
||||
// * Global cache store for mixin instances
|
||||
// * Uses WeakMap to avoid memory leaks when components are destroyed
|
||||
// */
|
||||
// const componentCaches = new WeakMap<
|
||||
// VueComponentWithMixin,
|
||||
// Map<string, CacheEntry<unknown>>
|
||||
// >();
|
||||
//
|
||||
// /**
|
||||
// * Cache configuration constants
|
||||
// */
|
||||
// const CACHE_DEFAULTS = {
|
||||
// default: 15000, // 15 seconds default TTL
|
||||
// } as const;
|
||||
|
||||
const _memoryLogs: string[] = [];
|
||||
|
||||
@@ -203,8 +203,8 @@ export const PlatformServiceMixin = {
|
||||
logger.debug(
|
||||
`[PlatformServiceMixin] ActiveDid updated from ${oldDid} to ${newDid}`,
|
||||
);
|
||||
// Clear caches that might be affected by the change
|
||||
this.$clearAllCaches();
|
||||
// // Clear caches that might be affected by the change
|
||||
// this.$clearAllCaches();
|
||||
}
|
||||
},
|
||||
|
||||
@@ -256,71 +256,71 @@ export const PlatformServiceMixin = {
|
||||
return (value as T) || defaultValue;
|
||||
},
|
||||
|
||||
// =================================================
|
||||
// CACHING UTILITY METHODS
|
||||
// =================================================
|
||||
// // =================================================
|
||||
// // CACHING UTILITY METHODS
|
||||
// // =================================================
|
||||
|
||||
/**
|
||||
* Get or initialize cache for this component instance
|
||||
*/
|
||||
_getCache(): Map<string, CacheEntry<unknown>> {
|
||||
let cache = componentCaches.get(this as unknown as VueComponentWithMixin);
|
||||
if (!cache) {
|
||||
cache = new Map();
|
||||
componentCaches.set(this as unknown as VueComponentWithMixin, cache);
|
||||
}
|
||||
return cache;
|
||||
},
|
||||
// /**
|
||||
// * Get or initialize cache for this component instance
|
||||
// */
|
||||
// _getCache(): Map<string, CacheEntry<unknown>> {
|
||||
// let cache = componentCaches.get(this as unknown as VueComponentWithMixin);
|
||||
// if (!cache) {
|
||||
// cache = new Map();
|
||||
// componentCaches.set(this as unknown as VueComponentWithMixin, cache);
|
||||
// }
|
||||
// return cache;
|
||||
// },
|
||||
|
||||
/**
|
||||
* Check if cache entry is valid (not expired)
|
||||
*/
|
||||
_isCacheValid(entry: CacheEntry<unknown>): boolean {
|
||||
return Date.now() - entry.timestamp < entry.ttl;
|
||||
},
|
||||
// /**
|
||||
// * Check if cache entry is valid (not expired)
|
||||
// */
|
||||
// _isCacheValid(entry: CacheEntry<unknown>): boolean {
|
||||
// return Date.now() - entry.timestamp < entry.ttl;
|
||||
// },
|
||||
|
||||
/**
|
||||
* Get data from cache if valid, otherwise return null
|
||||
*/
|
||||
_getCached<T>(key: string): T | null {
|
||||
const cache = this._getCache();
|
||||
const entry = cache.get(key);
|
||||
if (entry && this._isCacheValid(entry)) {
|
||||
return entry.data as T;
|
||||
}
|
||||
cache.delete(key); // Clean up expired entries
|
||||
return null;
|
||||
},
|
||||
// /**
|
||||
// * Get data from cache if valid, otherwise return null
|
||||
// */
|
||||
// _getCached<T>(key: string): T | null {
|
||||
// const cache = this._getCache();
|
||||
// const entry = cache.get(key);
|
||||
// if (entry && this._isCacheValid(entry)) {
|
||||
// return entry.data as T;
|
||||
// }
|
||||
// cache.delete(key); // Clean up expired entries
|
||||
// return null;
|
||||
// },
|
||||
|
||||
/**
|
||||
* Store data in cache with TTL
|
||||
*/
|
||||
_setCached<T>(key: string, data: T, ttl?: number): T {
|
||||
const cache = this._getCache();
|
||||
const actualTtl = ttl || CACHE_DEFAULTS.default;
|
||||
cache.set(key, {
|
||||
data,
|
||||
timestamp: Date.now(),
|
||||
ttl: actualTtl,
|
||||
});
|
||||
return data;
|
||||
},
|
||||
// /**
|
||||
// * Store data in cache with TTL
|
||||
// */
|
||||
// _setCached<T>(key: string, data: T, ttl?: number): T {
|
||||
// const cache = this._getCache();
|
||||
// const actualTtl = ttl || CACHE_DEFAULTS.default;
|
||||
// cache.set(key, {
|
||||
// data,
|
||||
// timestamp: Date.now(),
|
||||
// ttl: actualTtl,
|
||||
// });
|
||||
// return data;
|
||||
// },
|
||||
|
||||
/**
|
||||
* Invalidate specific cache entry
|
||||
*/
|
||||
_invalidateCache(key: string): void {
|
||||
const cache = this._getCache();
|
||||
cache.delete(key);
|
||||
},
|
||||
// /**
|
||||
// * Invalidate specific cache entry
|
||||
// */
|
||||
// _invalidateCache(key: string): void {
|
||||
// const cache = this._getCache();
|
||||
// cache.delete(key);
|
||||
// },
|
||||
|
||||
/**
|
||||
* Clear all cache entries for this component
|
||||
*/
|
||||
_clearCache(): void {
|
||||
const cache = this._getCache();
|
||||
cache.clear();
|
||||
},
|
||||
// /**
|
||||
// * Clear all cache entries for this component
|
||||
// */
|
||||
// _clearCache(): void {
|
||||
// const cache = this._getCache();
|
||||
// cache.clear();
|
||||
// },
|
||||
|
||||
// =================================================
|
||||
// ENHANCED DATABASE METHODS (with error handling)
|
||||
@@ -872,13 +872,13 @@ export const PlatformServiceMixin = {
|
||||
return await this.$contacts();
|
||||
},
|
||||
|
||||
/**
|
||||
* Clear all caches for this component - $clearAllCaches()
|
||||
* Useful for manual cache management
|
||||
*/
|
||||
$clearAllCaches(): void {
|
||||
this._clearCache();
|
||||
},
|
||||
// /**
|
||||
// * Clear all caches for this component - $clearAllCaches()
|
||||
// * Useful for manual cache management
|
||||
// */
|
||||
// $clearAllCaches(): void {
|
||||
// this._clearCache();
|
||||
// },
|
||||
|
||||
// =================================================
|
||||
// HIGH-LEVEL ENTITY OPERATIONS (eliminate verbose SQL patterns)
|
||||
|
||||
Reference in New Issue
Block a user