MCPcopy Create free account
hub / github.com/chhoumann/quickadd / clear

Method clear

src/utils/FieldSuggestionCache.ts:108–127  ·  view source on GitHub ↗

* Clear cache for a specific field or all cache * @param fieldName Optional field name to clear specific cache

(fieldName?: string)

Source from the content-addressed store, hash-verified

106 * @param fieldName Optional field name to clear specific cache
107 */
108 clear(fieldName?: string): void {
109 if (fieldName) {
110 // Clear all entries for this field. Compare the decoded field-name
111 // component rather than a raw `${fieldName}:` prefix, which would both
112 // over-match (a different field literally named `${fieldName}:...`) and
113 // mis-match once keys are JSON-encoded.
114 const keysToDelete: string[] = [];
115 for (const key of this.cache.keys()) {
116 if (this.keyFieldName(key) === fieldName) {
117 keysToDelete.push(key);
118 }
119 }
120 for (const key of keysToDelete) {
121 this.cache.delete(key);
122 }
123 } else {
124 // Clear entire cache
125 this.cache.clear();
126 }
127 }
128
129 /**
130 * Clear cache entries older than TTL

Calls 2

keyFieldNameMethod · 0.95
pushMethod · 0.80

Tested by

no test coverage detected