Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/keys.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ exports.del = function (mockInstance, keys, callback) {

if (keys[i] in mockInstance.storage) {

clearTimeout(mockInstance.storage[keys[i]]._expire);
delete mockInstance.storage[keys[i]];
keysDeleted++;

Expand Down
4 changes: 4 additions & 0 deletions lib/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
* flushdb
*/
exports.flushdb = flushdb = function (mockInstance, callback) {
for (var key in mockInstance.storage) {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could add a performance penalty if someone adds > 100000 keys ... 1 million keys takes 3 seconds on my hardware (2.7ghz).

clearTimeout(mockInstance.storage[key]._expire);
}

mockInstance.storage = {};

mockInstance._callCallback(callback, null, 'OK');
Expand Down