{"id":20504488,"url":"https://github.com/2naive/mysql2-cache","last_synced_at":"2025-10-07T22:40:52.173Z","repository":{"id":145217304,"uuid":"453562890","full_name":"2naive/mysql2-cache","owner":"2naive","description":"MySQL2 upgrade: cache mysql queries, easy shortcuts, logging and debugging.","archived":false,"fork":false,"pushed_at":"2024-10-19T00:40:38.000Z","size":27,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-05T20:55:28.318Z","etag":null,"topics":["mysql","mysql-cache","mysql2","node-cache","node-mysql","node-mysql2"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/2naive.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-01-30T01:40:54.000Z","updated_at":"2024-10-19T00:40:42.000Z","dependencies_parsed_at":"2024-11-15T19:38:29.928Z","dependency_job_id":"7fca1f69-21bc-46ec-9d32-9fd28791c45c","html_url":"https://github.com/2naive/mysql2-cache","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/2naive/mysql2-cache","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/2naive%2Fmysql2-cache","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/2naive%2Fmysql2-cache/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/2naive%2Fmysql2-cache/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/2naive%2Fmysql2-cache/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/2naive","download_url":"https://codeload.github.com/2naive/mysql2-cache/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/2naive%2Fmysql2-cache/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278861034,"owners_count":26058631,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-07T02:00:06.786Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["mysql","mysql-cache","mysql2","node-cache","node-mysql","node-mysql2"],"created_at":"2024-11-15T19:38:23.279Z","updated_at":"2025-10-07T22:40:52.110Z","avatar_url":"https://github.com/2naive.png","language":"JavaScript","readme":"# mysql2-cache\n\n[![NPM](https://nodei.co/npm/mysql2-cache.png?downloads=true\u0026stars=true)](https://nodei.co/npm/mysql2-cache/)\n\n![GitHub release (latest by date)](https://img.shields.io/github/v/release/2naive/mysql2-cache)\n![node-current](https://img.shields.io/node/v/mysql2-cache)\n![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/2naive/mysql2-cache/node.js.yml?branch=master)\n![Coveralls github](https://img.shields.io/coveralls/github/2naive/mysql2-cache)\n![Standard - JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)\n\n\u003e ✔ MySQL2 upgrade: cache queries, easy shortcuts, logging and debugging.\n\n## Installation\n\n```bash\nnpm install mysql2-cache --save\n```\n\n## Sample Usage\n\n```javascript\nconst mysql = require('mysql2-cache')\nconst db = mysql.connect({\n  host: 'localhost',\n  user: 'root',\n  database: 'test',\n  password: 'root'\n})\ndb.q('SELECT * FROM test_table').then(res =\u003e console.dir)\n```\n\n## Cache queries\n\n```javascript\nconst mysql = require('mysql2-cache')\nconst db = mysql.connect({\n  host: 'localhost',\n  user: 'root',\n  database: 'test',\n  password: 'root'\n})\ndb.q('SELECT * FROM test_table WHERE id=?', 1, true) // use cache with default ttl=300s\ndb.q('SELECT * FROM test_table WHERE id=?', 1, true, 300) // ttl in seconds\n```\n\n## Debugging easy\n\nPass `DEBUG=mysql2-cache*` environment variable to pretty debug.\n\n```bash\n  mysql2-cache:1 SELECT * FROM test_table WHERE age \u003e ? [1] +0ms\n  mysql2-cache:1 ┌─────────┬─────────┬─────┐\n  mysql2-cache:1 │ (index) │  name   │ age │\n  mysql2-cache:1 ├─────────┼─────────┼─────┤\n  mysql2-cache:1 │    0    │ 'Alice' │ 90  │\n  mysql2-cache:1 │    1    │  'Bob'  │ 42  │\n  mysql2-cache:1 └─────────┴─────────┴─────┘\n  mysql2-cache:1  +32ms\n```\n\n## API\n\nYou may use all [MySQL2](https://github.com/sidorares/node-mysql2) methods plus:\n\n### connect([PoolOptions](https://sidorares.github.io/node-mysql2/docs#using-connection-pools))\n\n### async q(sql, params = [], cache = false, ttl = undefined)\n\n### async qRow(sql, params = [], cache = false, ttl = undefined)\n\n### async insert(table, row)\n\n### async update(table, row, where = false)\n\n### async delete(table, row, where = false)\n\n### stat()\n\n### cacheFlush(sql, params)\n\n### cacheFlushAll()\n\n### cacheStat()\n\n## Getting help\n\nIf you've found a bug in the library or would like new features added, go ahead and open issues or pull requests against this repo!\n\n## Contributing\n\nBug fixes, docs, and library improvements are always welcome. Please refer to our [Contributing Guide](CONTRIBUTING.md) for detailed information on how you can contribute.\nIf you're not familiar with the GitHub pull request/contribution process, [this is a nice tutorial](https://gun.io/blog/how-to-github-fork-branch-and-pull-request/).\n\n### Getting Started\n\nIf you want to familiarize yourself with the project, you can start by [forking the repository](https://help.github.com/articles/fork-a-repo/) and [cloning it in your local development environment](https://help.github.com/articles/cloning-a-repository/). The project requires [Node.js](https://nodejs.org) to be installed on your machine.\n\nAfter cloning the repository, install the dependencies by running the following command in the directory of your cloned repository:\n\n```bash\nnpm install\n```\n\nYou can run the existing tests to see if everything is okay by executing:\n\n```bash\nnpm test\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F2naive%2Fmysql2-cache","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F2naive%2Fmysql2-cache","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F2naive%2Fmysql2-cache/lists"}