@live-change/dao 0.9.117 → 0.9.119
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/lib/DaoCache.js +3 -0
- package/package.json +2 -2
package/lib/DaoCache.js
CHANGED
|
@@ -100,6 +100,7 @@ const defaultSettings = {
|
|
|
100
100
|
deleteStatsScore: 0.2,
|
|
101
101
|
cleanInterval: 1000, // 1 second
|
|
102
102
|
cacheAdaptationFactor: 0.5, // cache add adaptation factor
|
|
103
|
+
cacheFilter: (path) => true
|
|
103
104
|
}
|
|
104
105
|
|
|
105
106
|
class DaoCache extends EventEmitter {
|
|
@@ -224,6 +225,7 @@ class DaoCache extends EventEmitter {
|
|
|
224
225
|
}
|
|
225
226
|
|
|
226
227
|
observable(what) {
|
|
228
|
+
if(!this.settings.cacheFilter(what)) return this.dao.observable(what)
|
|
227
229
|
//console.log("CACHE OBSERVABLE", what)
|
|
228
230
|
const observable = this.dao.observable(what)
|
|
229
231
|
const oldObserve = observable.observe
|
|
@@ -241,6 +243,7 @@ class DaoCache extends EventEmitter {
|
|
|
241
243
|
|
|
242
244
|
get(what) {
|
|
243
245
|
//console.log("CACHE GET", what)
|
|
246
|
+
if(!this.settings.cacheFilter(what)) return this.dao.get(what)
|
|
244
247
|
const cacheState = this.getOrCreateCacheState(what)
|
|
245
248
|
if(cacheState) {
|
|
246
249
|
cacheState.noticeSingleRead()
|
package/package.json
CHANGED