File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed
Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -81,6 +81,16 @@ export class Cache<T> {
8181 this . cache . set ( key , { data, timestamp : Date . now ( ) } ) ;
8282 }
8383
84+ /**
85+ * Checks if a key exists in the cache without removing expired entries.
86+ *
87+ * @param key - The key to check.
88+ * @returns True if the key exists in the cache, false otherwise.
89+ */
90+ has ( key : string ) : boolean {
91+ return this . cache . has ( key ) ;
92+ }
93+
8494 /**
8595 * Retrieves an entry from the cache.
8696 *
@@ -106,7 +116,7 @@ export class Cache<T> {
106116 * Disposes of resources used by the cache instance.
107117 *
108118 * This method clears the interval used for cleanup and clears the cache.
109- * It should be called when the client is no longer needed to prevent memory leaks.
119+ * It should be called when the cache instance is no longer needed to prevent memory leaks.
110120 */
111121 dispose ( ) : void {
112122 clearInterval ( this . cleanupInterval ) ;
You can’t perform that action at this time.
0 commit comments