cache and procedure

Open
#929 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
25/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Stale
Tech stack
express, javascript, mysql, node.js
Domain
backend, databases

Research direction

Start by reproducing the reported behavior with the provided mysql.createPool and mysqlpool.query CALL example, varying the procedure parameters across requests. Read the mysql2 LRU-cache documentation and compare repeated procedure results; done means establishing whether the stale rows come from mysql2 or the procedure/database and recording a clear resolution.

Written by the indexing model from the issue text.

Description

Dear developers
i am use mysql2 lib with PoolConnection on ExpressJS.
When I make a two request (changing the parameters of the request), I get old (cached) data sometimes (reloading the page). Is it somehow connected with Lru cached, but it is impossible to disable it through the connection parameters or it bug?

in docunetation say:
// If you execute same statement again, it will be picked from a LRU cache
// which will save query preparation time and give better performance
but i use Procedure and PoolQuery . Patching my CALL procedure added Math.Random but it had no effect

my source code

const mysql = require('mysql2');
const mysqlpool = mysql.createPool({
    host: 'localhost',
    user: 'root',
    database: 'base_test',
    waitForConnections: true,
    connectionLimit: 10,
    queueLimit: 0,
    multipleStatements: false,
    //caching: true
});

module.exports.getQuery = function (str,brand,resout) {
    let rnd = Math.random();
    let sqlProcedure = 'CALL alfaquery_v2(?,?);';
    mysqlpool.query(
        sqlProcedure,[str,rnd],
        function(err, rows) {
            if (err) {
                console.log(err);
                resout.send([]);
            }
            console.log(rows[0]);
            resout.send(rows[0]);
        });
}

Dominant language
TypeScript
Stars
4.4k
Forks
680
Avg merge
9h 7m
Merged PRs (30d)
59

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from sidorares/node-mysql2

All issues in sidorares/node-mysql2

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.