You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
1.3 KiB

# @keyvhq/mysql [<img width="100" align="right" src="https://ghcdn.rawgit.org/microlinkhq/keyv/master/media/logo-sunset.svg" alt="keyv">](https://github.com/microlinkhq/keyv)
3 years ago
> MySQL/MariaDB storage adapter for [Keyv](https://github.com/microlinkhq/keyv).
## Install
```shell
npm install --save keyv @keyvhq/mysql
3 years ago
```
## Usage
```js
const Keyv = require('keyv')
const keyv = new Keyv('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:
```js
const keyv = new Keyv('mysql://user:pass@localhost:3306/dbname', {
table: 'cache',
keySize: 255
})
```
3 years ago
**Note:** Some MySQL/MariaDB installations won't allow a key size longer than 767 bytes. If you get an error on table creation try reducing `keySize` to 191 or lower.
3 years ago
## License
**@keyvhq/mysql** © [Microlink](https://microlink.io), Released under the [MIT](https://github.com/microlinkhq/keyv/blob/master/LICENSE.md) License.<br/>
Authored and maintained by [Microlink](https://microlink.io) with help from [contributors](https://github.com/microlinkhq/keyv/contributors).
> [microlink.io](https://microlink.io) · GitHub [@MicrolinkHQ](https://github.com/microlinkhq) · Twitter [@microlinkhq](https://twitter.com/microlinkhq)