@keyv/mysql
TypeScript icon, indicating that this package has built-in type declarations

2.0.1 • Public • Published

@keyv/mysql keyv

MySQL/MariaDB storage adapter for Keyv

build codecov npm npm

MySQL/MariaDB storage adapter for Keyv.

Install

npm install --save keyv @keyv/mysql

Usage

import Keyv from 'keyv';
import KeyvMysql from '@keyv/mysql';

const keyv = new Keyv(new KeyvMysql('mysql://user:pass@localhost:3306/dbname'));
keyv.on('error', handleConnectionError);

You can specify a custom table with the table option and the primary key size with keySize.

e.g:

import Keyv from 'keyv';
import KeyvMysql from '@keyv/mysql';

const keyv = new Keyv(new KeyvMysql('mysql://user:pass@localhost:3306/dbname'), {
  table: 'cache',
  keySize: 255
});

SSL

import Keyv from 'keyv';
import KeyvMysql from '@keyv/mysql';
import fs from 'fs';

const options = {
	ssl: {
		rejectUnauthorized: false,
		ca: fs.readFileSync(path.join(__dirname, '/certs/ca.pem')).toString(),
		key: fs.readFileSync(path.join(__dirname, '/certs/client-key.pem')).toString(),
		cert: fs.readFileSync(path.join(__dirname, '/certs/client-cert.pem')).toString(),
	},
};

const keyvMysql = new KeyvMysql('mysql://user:pass@localhost:3306/dbname', options);
const keyv = new Keyv({ store: keyvMysql });

License

MIT © Jared Wray

/@keyv/mysql/

    Package Sidebar

    Install

    npm i @keyv/mysql

    Weekly Downloads

    415

    Version

    2.0.1

    License

    MIT

    Unpacked Size

    20 kB

    Total Files

    9

    Last publish

    Collaborators

    • jaredwray
    • lukechilds