@live-change/dao 0.3.10 → 0.3.11

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.
Files changed (2) hide show
  1. package/lib/DaoCache.js +14 -0
  2. package/package.json +1 -1
package/lib/DaoCache.js CHANGED
@@ -83,6 +83,12 @@ class CacheState {
83
83
  }
84
84
  this.updateCacheState()
85
85
  }
86
+
87
+ dipose() {
88
+ if(this.cached) {
89
+ this.observable.unobserve(this.cache.dummyObserver)
90
+ }
91
+ }
86
92
  }
87
93
 
88
94
  const defaultSettings = {
@@ -133,6 +139,12 @@ class DaoCache extends EventEmitter {
133
139
  this.dummyObserver = () => 0
134
140
  }
135
141
 
142
+ clear() {
143
+ for(const [key, value] of this.cacheState.entries()) {
144
+ value.dispose()
145
+ this.cacheState.delete(key)
146
+ }
147
+ }
136
148
 
137
149
  clean() {
138
150
  //console.log("CACHE STATE:", this.cacheState)
@@ -165,6 +177,7 @@ class DaoCache extends EventEmitter {
165
177
  }
166
178
  for(const [key, value] of this.cacheState.entries()) {
167
179
  if(value.score < value.settings.deleteStatsScore) {
180
+ this.cacheState.dispose()
168
181
  this.cacheState.delete(key)
169
182
  }
170
183
  }
@@ -253,6 +266,7 @@ class DaoCache extends EventEmitter {
253
266
  }
254
267
 
255
268
  dispose() {
269
+ clear()
256
270
  clearInterval(this.interval)
257
271
  this.dao.dispose()
258
272
  }
package/package.json CHANGED
@@ -36,5 +36,5 @@
36
36
  "scripts": {
37
37
  "test": "NODE_ENV=test blue-tape tests/*"
38
38
  },
39
- "version": "0.3.10"
39
+ "version": "0.3.11"
40
40
  }