mysql2 3.11.0 → 3.11.2

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/connection.js CHANGED
@@ -22,7 +22,7 @@ const EventEmitter = require('events').EventEmitter;
22
22
  const Readable = require('stream').Readable;
23
23
  const Queue = require('denque');
24
24
  const SqlString = require('sqlstring');
25
- const LRU = require('lru-cache').default;
25
+ const { createLRU } = require('lru.min');
26
26
 
27
27
  const PacketParser = require('./packet_parser.js');
28
28
  const Packets = require('./packets/index.js');
@@ -75,9 +75,9 @@ class Connection extends EventEmitter {
75
75
  this._command = null;
76
76
  this._paused = false;
77
77
  this._paused_packets = new Queue();
78
- this._statements = new LRU({
78
+ this._statements = createLRU({
79
79
  max: this.config.maxPreparedStatements,
80
- dispose: function(statement) {
80
+ onEviction: function(_, statement) {
81
81
  statement.close();
82
82
  }
83
83
  });
@@ -411,7 +411,7 @@ class Connection extends EventEmitter {
411
411
  err.code = code || 'PROTOCOL_ERROR';
412
412
  this.emit('error', err);
413
413
  }
414
-
414
+
415
415
  get fatalError() {
416
416
  return this._fatalError;
417
417
  }
@@ -1,8 +1,8 @@
1
1
  'use strict';
2
2
 
3
- const LRU = require('lru-cache').default;
3
+ const { createLRU } = require('lru.min');
4
4
 
5
- let parserCache = new LRU({
5
+ const parserCache = createLRU({
6
6
  max: 15000,
7
7
  });
8
8
 
@@ -51,7 +51,7 @@ function getParser(type, fields, options, config, compiler) {
51
51
  }
52
52
 
53
53
  function setMaxCache(max) {
54
- parserCache = new LRU({ max });
54
+ parserCache.resize(max);
55
55
  }
56
56
 
57
57
  function clearCache() {
@@ -1,9 +1,9 @@
1
1
  'use strict';
2
2
 
3
3
  const Iconv = require('iconv-lite');
4
- const LRU = require('lru-cache').default;
4
+ const { createLRU } = require('lru.min');
5
5
 
6
- const decoderCache = new LRU({
6
+ const decoderCache = createLRU({
7
7
  max: 500,
8
8
  });
9
9
 
package/lib/pool.js CHANGED
@@ -200,9 +200,10 @@ class Pool extends EventEmitter {
200
200
  this._removeIdleTimeoutConnectionsTimer = setTimeout(() => {
201
201
  try {
202
202
  while (
203
- this._freeConnections.length > this.config.maxIdle &&
204
- Date.now() - this._freeConnections.get(0).lastActiveTime >
205
- this.config.idleTimeout
203
+ this._freeConnections.length > this.config.maxIdle ||
204
+ (this._freeConnections.length > 0 &&
205
+ Date.now() - this._freeConnections.get(0).lastActiveTime >
206
+ this.config.idleTimeout)
206
207
  ) {
207
208
  this._freeConnections.get(0).destroy();
208
209
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mysql2",
3
- "version": "3.11.0",
3
+ "version": "3.11.2",
4
4
  "description": "fast mysql driver. Implements core protocol, prepared statements, ssl and compression in native JS",
5
5
  "main": "index.js",
6
6
  "typings": "typings/mysql/index",
@@ -63,13 +63,13 @@
63
63
  "generate-function": "^2.3.1",
64
64
  "iconv-lite": "^0.6.3",
65
65
  "long": "^5.2.1",
66
- "lru-cache": "^8.0.0",
66
+ "lru.min": "^1.0.0",
67
67
  "named-placeholders": "^1.1.3",
68
68
  "seq-queue": "^0.0.5",
69
69
  "sqlstring": "^2.3.2"
70
70
  },
71
71
  "devDependencies": {
72
- "@types/node": "^20.0.0",
72
+ "@types/node": "^22.0.0",
73
73
  "@typescript-eslint/eslint-plugin": "^5.42.1",
74
74
  "@typescript-eslint/parser": "^5.42.1",
75
75
  "assert-diff": "^3.0.2",
package/promise.js CHANGED
@@ -451,10 +451,10 @@ class PromisePoolCluster extends EventEmitter {
451
451
  inheritEvents(poolCluster, this, ['warn', 'remove']);
452
452
  }
453
453
 
454
- getConnection() {
454
+ getConnection(pattern, selector) {
455
455
  const corePoolCluster = this.poolCluster;
456
456
  return new this.Promise((resolve, reject) => {
457
- corePoolCluster.getConnection((err, coreConnection) => {
457
+ corePoolCluster.getConnection(pattern, selector, (err, coreConnection) => {
458
458
  if (err) {
459
459
  reject(err);
460
460
  } else {