mentie 0.3.18 → 0.3.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/modules/cache.js +12 -1
- package/package.json +1 -1
package/modules/cache.js
CHANGED
|
@@ -5,7 +5,7 @@ import { log } from "./logging.js"
|
|
|
5
5
|
* @type {Object}
|
|
6
6
|
* @private
|
|
7
7
|
*/
|
|
8
|
-
|
|
8
|
+
let _cache = {}
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Caches the value with the specified key.
|
|
@@ -101,6 +101,17 @@ cache.dump = () => {
|
|
|
101
101
|
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
+
/**
|
|
105
|
+
* Clears the cache entirely
|
|
106
|
+
*/
|
|
107
|
+
cache.clear = ( { i_am_sure=false } ) => {
|
|
108
|
+
if( i_am_sure ) {
|
|
109
|
+
_cache = {}
|
|
110
|
+
} else {
|
|
111
|
+
log.warn( `cache.clear() called without i_am_sure=true, cache not cleared` )
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
104
115
|
/**
|
|
105
116
|
*
|
|
106
117
|
* @returns {Object} stats - An object containing statistics about the cache.
|