Skip to content

Commit cfae27a

Browse files
committed
Fix LiveMysql.resume() and test case for removing queryCache buffer
1 parent 548a699 commit cfae27a

File tree

4 files changed

+10
-6
lines changed

4 files changed

+10
-6
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
*.*~
22
*.swp
33
*.swo
4+
*.swn
45
.npm
56
node_modules

lib/LiveMysql.js

+7-4
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ function LiveMysql(settings, callback){
4444
queryCache.invalidate();
4545
}
4646
}
47-
});
47+
})
4848

4949
// Wait for Zongji to be ready before executing callback
5050
var zongjiInitTime = Date.now();
@@ -149,9 +149,12 @@ LiveMysql.prototype.resume = function(){
149149
self.zongji.set(self.zongjiSettings);
150150

151151
// Update all select statements
152-
self._select.forEach(function(select) {
153-
select.update();
154-
});
152+
for(var query in self._queryCache){
153+
if (!self._queryCache.hasOwnProperty(query)){
154+
continue;
155+
}
156+
self._queryCache[query].invalidate();
157+
}
155158
};
156159

157160
LiveMysql.prototype.end = function(){

lib/QueryCache.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* mysql-live-select, MIT License [email protected]
1+
/* mysql-live-select, MIT License [email protected], [email protected]
22
lib/QueryCache.js - Query Results Cache Class */
33

44
// Many LiveMysqlSelect objects can share the same query cache if they have the

test/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ module.exports = {
266266
this.stop();
267267
// When all instances of query removed, resultsBuffer removed too
268268
// TODO: Update for queryCache
269-
// test.equal(typeof conn._resultsBuffer[query], 'undefined');
269+
test.equal(typeof conn._queryCache[query], 'undefined');
270270

271271
test.ok(!this.active());
272272
conn.db.query('DELETE FROM ' + escId(table));

0 commit comments

Comments
 (0)