Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: resolve LRU conflicts and premature engine breaking change #21

Closed
wants to merge 5 commits into from
Closed
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
8 changes: 4 additions & 4 deletions lib/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const EventEmitter = require('events').EventEmitter;
const Readable = require('stream').Readable;
const Queue = require('denque');
const SqlString = require('sqlstring');
const LRU = require('lru-cache').default;
const { createLRU } = require('lru.min');

const PacketParser = require('./packet_parser.js');
const Packets = require('./packets/index.js');
Expand Down Expand Up @@ -75,9 +75,9 @@ class Connection extends EventEmitter {
this._command = null;
this._paused = false;
this._paused_packets = new Queue();
this._statements = new LRU({
this._statements = createLRU({
max: this.config.maxPreparedStatements,
dispose: function(statement) {
onEviction: function(_, statement) {
statement.close();
}
});
Expand Down Expand Up @@ -411,7 +411,7 @@ class Connection extends EventEmitter {
err.code = code || 'PROTOCOL_ERROR';
this.emit('error', err);
}

get fatalError() {
return this._fatalError;
}
Expand Down
6 changes: 3 additions & 3 deletions lib/parsers/parser_cache.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
'use strict';

const LRU = require('lru-cache').default;
const { createLRU } = require('lru.min');

let parserCache = new LRU({
const parserCache = createLRU({
max: 15000,
});

Expand Down Expand Up @@ -51,7 +51,7 @@ function getParser(type, fields, options, config, compiler) {
}

function setMaxCache(max) {
parserCache = new LRU({ max });
parserCache.resize(max);
}

function clearCache() {
Expand Down
4 changes: 2 additions & 2 deletions lib/parsers/string.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
'use strict';

const Iconv = require('iconv-lite');
const LRU = require('lru-cache').default;
const { createLRU } = require('lru.min');

const decoderCache = new LRU({
const decoderCache = createLRU({
max: 500,
});

Expand Down
27 changes: 17 additions & 10 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"generate-function": "^2.3.1",
"iconv-lite": "^0.6.3",
"long": "^5.2.1",
"lru-cache": "^8.0.0",
"lru.min": "^1.0.0",
"named-placeholders": "^1.1.3",
"seq-queue": "^0.0.5",
"sqlstring": "^2.3.2"
Expand Down
Loading