From a387d0edae5a4ccfc0c995cdaf79a93657e30628 Mon Sep 17 00:00:00 2001 From: Kiko Beats Date: Fri, 16 Jul 2021 10:00:27 +0200 Subject: [PATCH] docs: tweaks --- CHANGELOG.md | 18 +- README.md | 10 +- packages/{keyv => core}/CHANGELOG.md | 0 packages/{keyv => core}/package.json | 0 packages/{keyv => core}/src/index.js | 0 packages/{keyv => core}/test/keyv.js | 0 packages/keyv-mongo/README.md | 39 --- packages/keyv-mysql/README.md | 42 --- packages/keyv-postgres/README.md | 39 --- packages/keyv-sql/README.md | 18 -- packages/keyv-sqlite/README.md | 40 --- packages/keyv-test-suite/README.md | 68 ---- packages/keyv/README.md | 296 ------------------ packages/{keyv-mongo => mongo}/CHANGELOG.md | 0 packages/mongo/README.md | 35 +++ packages/{keyv-mongo => mongo}/package.json | 2 +- packages/{keyv-mongo => mongo}/src/index.js | 0 packages/{keyv-mongo => mongo}/test/index.js | 0 packages/{keyv-mysql => mysql}/CHANGELOG.md | 0 packages/mysql/README.md | 38 +++ packages/{keyv-mysql => mysql}/package.json | 0 packages/{keyv-mysql => mysql}/src/index.js | 0 packages/{keyv-mysql => mysql}/test/index.js | 0 .../{keyv-postgres => postgres}/CHANGELOG.md | 0 packages/postgres/README.md | 35 +++ .../{keyv-postgres => postgres}/package.json | 0 .../{keyv-postgres => postgres}/src/index.js | 0 .../{keyv-postgres => postgres}/test/index.js | 0 packages/{keyv-redis => redis}/CHANGELOG.md | 0 packages/{keyv-redis => redis}/Dockerfile | 0 packages/{keyv-redis => redis}/README.md | 16 +- .../{keyv-redis => redis}/docker-compose.yml | 0 packages/{keyv-redis => redis}/package.json | 2 +- packages/{keyv-redis => redis}/src/index.js | 0 packages/{keyv-redis => redis}/test/index.js | 0 packages/{keyv-sql => sql}/CHANGELOG.md | 0 packages/sql/README.md | 14 + packages/{keyv-sql => sql}/package.json | 2 +- packages/{keyv-sql => sql}/src/index.js | 0 packages/{keyv-sql => sql}/test/index.js | 0 packages/{keyv-sqlite => sqlite}/CHANGELOG.md | 0 packages/sqlite/README.md | 36 +++ packages/{keyv-sqlite => sqlite}/package.json | 2 +- packages/{keyv-sqlite => sqlite}/src/index.js | 0 .../{keyv-sqlite => sqlite}/test/index.js | 0 .../CHANGELOG.md | 0 packages/test-suite/README.md | 64 ++++ .../package.json | 0 .../src/api.js | 0 .../src/index.js | 0 .../src/iteration.js | 0 .../src/namespace.js | 0 .../src/values.js | 0 53 files changed, 246 insertions(+), 570 deletions(-) rename packages/{keyv => core}/CHANGELOG.md (100%) rename packages/{keyv => core}/package.json (100%) rename packages/{keyv => core}/src/index.js (100%) rename packages/{keyv => core}/test/keyv.js (100%) delete mode 100644 packages/keyv-mongo/README.md delete mode 100644 packages/keyv-mysql/README.md delete mode 100644 packages/keyv-postgres/README.md delete mode 100644 packages/keyv-sql/README.md delete mode 100644 packages/keyv-sqlite/README.md delete mode 100644 packages/keyv-test-suite/README.md delete mode 100644 packages/keyv/README.md rename packages/{keyv-mongo => mongo}/CHANGELOG.md (100%) create mode 100644 packages/mongo/README.md rename packages/{keyv-mongo => mongo}/package.json (96%) rename packages/{keyv-mongo => mongo}/src/index.js (100%) rename packages/{keyv-mongo => mongo}/test/index.js (100%) rename packages/{keyv-mysql => mysql}/CHANGELOG.md (100%) create mode 100644 packages/mysql/README.md rename packages/{keyv-mysql => mysql}/package.json (100%) rename packages/{keyv-mysql => mysql}/src/index.js (100%) rename packages/{keyv-mysql => mysql}/test/index.js (100%) rename packages/{keyv-postgres => postgres}/CHANGELOG.md (100%) create mode 100644 packages/postgres/README.md rename packages/{keyv-postgres => postgres}/package.json (100%) rename packages/{keyv-postgres => postgres}/src/index.js (100%) rename packages/{keyv-postgres => postgres}/test/index.js (100%) rename packages/{keyv-redis => redis}/CHANGELOG.md (100%) rename packages/{keyv-redis => redis}/Dockerfile (100%) rename packages/{keyv-redis => redis}/README.md (54%) rename packages/{keyv-redis => redis}/docker-compose.yml (100%) rename packages/{keyv-redis => redis}/package.json (96%) rename packages/{keyv-redis => redis}/src/index.js (100%) rename packages/{keyv-redis => redis}/test/index.js (100%) rename packages/{keyv-sql => sql}/CHANGELOG.md (100%) create mode 100644 packages/sql/README.md rename packages/{keyv-sql => sql}/package.json (96%) rename packages/{keyv-sql => sql}/src/index.js (100%) rename packages/{keyv-sql => sql}/test/index.js (100%) rename packages/{keyv-sqlite => sqlite}/CHANGELOG.md (100%) create mode 100644 packages/sqlite/README.md rename packages/{keyv-sqlite => sqlite}/package.json (96%) rename packages/{keyv-sqlite => sqlite}/src/index.js (100%) rename packages/{keyv-sqlite => sqlite}/test/index.js (100%) rename packages/{keyv-test-suite => test-suite}/CHANGELOG.md (100%) create mode 100644 packages/test-suite/README.md rename packages/{keyv-test-suite => test-suite}/package.json (100%) rename packages/{keyv-test-suite => test-suite}/src/api.js (100%) rename packages/{keyv-test-suite => test-suite}/src/index.js (100%) rename packages/{keyv-test-suite => test-suite}/src/iteration.js (100%) rename packages/{keyv-test-suite => test-suite}/src/namespace.js (100%) rename packages/{keyv-test-suite => test-suite}/src/values.js (100%) diff --git a/CHANGELOG.md b/CHANGELOG.md index c44b483..6bd5354 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -79,15 +79,15 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline * **package:** update @keyv/sql to version 1.1.2 ([#20](https://github.com/microlinkhq/keyv/issues/20)) ([8545d89](https://github.com/microlinkhq/keyv/commit/8545d89d4d2666b188ec9c21b37385743686dc83)) * **package:** update json-buffer to version 3.0.1 ([b3f8119](https://github.com/microlinkhq/keyv/commit/b3f81193acc7f2ed661c4adaae461ba816061389)) * **package:** update keyv-sequelize to version 0.1.0 ([#3](https://github.com/microlinkhq/keyv/issues/3)) ([fddf4de](https://github.com/microlinkhq/keyv/commit/fddf4de9a9e8b679b5f07b719279abbb50d53e2f)) -* **package:** update keyv-sql to version 0.2.0 ([#6](https://github.com/microlinkhq/keyv/issues/6)) ([e74c6a9](https://github.com/microlinkhq/keyv/commit/e74c6a97279a79d3cdde4010a2d244c64aaf5522)) -* **package:** update keyv-sql to version 0.2.3 ([#8](https://github.com/microlinkhq/keyv/issues/8)) ([c270bb8](https://github.com/microlinkhq/keyv/commit/c270bb83f6935fae414137fa582423d3bbd33f0b)), closes [#7](https://github.com/microlinkhq/keyv/issues/7) -* **package:** update keyv-sql to version 0.2.4 ([#4](https://github.com/microlinkhq/keyv/issues/4)) ([1f6e98f](https://github.com/microlinkhq/keyv/commit/1f6e98f026e57a456fee365ce9dc56cde5f70ba3)) -* **package:** update keyv-sql to version 0.2.4 ([#4](https://github.com/microlinkhq/keyv/issues/4)) ([dee04f0](https://github.com/microlinkhq/keyv/commit/dee04f066cf9991c7a800476124c910e482580e5)) -* **package:** update keyv-sql to version 0.2.4 ([#9](https://github.com/microlinkhq/keyv/issues/9)) ([c30c07e](https://github.com/microlinkhq/keyv/commit/c30c07e70ed7df115e0dcbd9854bd76f0cf8154b)) -* **package:** update keyv-sql to version 1.0.2 ([#11](https://github.com/microlinkhq/keyv/issues/11)) ([b191741](https://github.com/microlinkhq/keyv/commit/b1917411eeaa04b6f29afb96810ddf5258926b27)), closes [#10](https://github.com/microlinkhq/keyv/issues/10) -* **package:** update keyv-sql to version 1.0.2 ([#6](https://github.com/microlinkhq/keyv/issues/6)) ([7e7e235](https://github.com/microlinkhq/keyv/commit/7e7e235aacc3e5699556da480769084944f5a0de)), closes [#5](https://github.com/microlinkhq/keyv/issues/5) -* **package:** update keyv-sql to version 1.0.2 ([#6](https://github.com/microlinkhq/keyv/issues/6)) ([26e3e96](https://github.com/microlinkhq/keyv/commit/26e3e963fa4773f92eb0f21ce8632e5ffb1b3889)), closes [#5](https://github.com/microlinkhq/keyv/issues/5) -* **package:** update keyv-sql to version 1.0.3 ([#9](https://github.com/microlinkhq/keyv/issues/9)) ([c72121d](https://github.com/microlinkhq/keyv/commit/c72121dddfab8672bfd86232242813c8b670f5e5)) +* **package:** update sql to version 0.2.0 ([#6](https://github.com/microlinkhq/keyv/issues/6)) ([e74c6a9](https://github.com/microlinkhq/keyv/commit/e74c6a97279a79d3cdde4010a2d244c64aaf5522)) +* **package:** update sql to version 0.2.3 ([#8](https://github.com/microlinkhq/keyv/issues/8)) ([c270bb8](https://github.com/microlinkhq/keyv/commit/c270bb83f6935fae414137fa582423d3bbd33f0b)), closes [#7](https://github.com/microlinkhq/keyv/issues/7) +* **package:** update sql to version 0.2.4 ([#4](https://github.com/microlinkhq/keyv/issues/4)) ([1f6e98f](https://github.com/microlinkhq/keyv/commit/1f6e98f026e57a456fee365ce9dc56cde5f70ba3)) +* **package:** update sql to version 0.2.4 ([#4](https://github.com/microlinkhq/keyv/issues/4)) ([dee04f0](https://github.com/microlinkhq/keyv/commit/dee04f066cf9991c7a800476124c910e482580e5)) +* **package:** update sql to version 0.2.4 ([#9](https://github.com/microlinkhq/keyv/issues/9)) ([c30c07e](https://github.com/microlinkhq/keyv/commit/c30c07e70ed7df115e0dcbd9854bd76f0cf8154b)) +* **package:** update sql to version 1.0.2 ([#11](https://github.com/microlinkhq/keyv/issues/11)) ([b191741](https://github.com/microlinkhq/keyv/commit/b1917411eeaa04b6f29afb96810ddf5258926b27)), closes [#10](https://github.com/microlinkhq/keyv/issues/10) +* **package:** update sql to version 1.0.2 ([#6](https://github.com/microlinkhq/keyv/issues/6)) ([7e7e235](https://github.com/microlinkhq/keyv/commit/7e7e235aacc3e5699556da480769084944f5a0de)), closes [#5](https://github.com/microlinkhq/keyv/issues/5) +* **package:** update sql to version 1.0.2 ([#6](https://github.com/microlinkhq/keyv/issues/6)) ([26e3e96](https://github.com/microlinkhq/keyv/commit/26e3e963fa4773f92eb0f21ce8632e5ffb1b3889)), closes [#5](https://github.com/microlinkhq/keyv/issues/5) +* **package:** update sql to version 1.0.3 ([#9](https://github.com/microlinkhq/keyv/issues/9)) ([c72121d](https://github.com/microlinkhq/keyv/commit/c72121dddfab8672bfd86232242813c8b670f5e5)) * **package:** update mysql2 to version 1.4.2 ([#17](https://github.com/microlinkhq/keyv/issues/17)) ([fd78034](https://github.com/microlinkhq/keyv/commit/fd7803444bafa1932905c9a927cbf373a58b4724)) * **package:** update pg to version 7.2.0 ([#15](https://github.com/microlinkhq/keyv/issues/15)) ([261f1b6](https://github.com/microlinkhq/keyv/commit/261f1b6f6e3484f5ae80ff72f5cc10eb1fcb328e)) * **package:** update sqlite3 to version 3.1.9 ([#13](https://github.com/microlinkhq/keyv/issues/13)) ([0255ff3](https://github.com/microlinkhq/keyv/commit/0255ff33a22e9e3790ed2dad5a75ac19aa194d6d)) diff --git a/README.md b/README.md index 45fbcd0..296dff8 100644 --- a/README.md +++ b/README.md @@ -141,11 +141,11 @@ You should also set a [`namespace`](#optionsnamespace) for your module so you ca > The official storage adapters are covered by [over 150 integration tests](https://github.com/microlinkhq/keyv/actions/runs/949262324) to guarantee consistent behaviour. They are lightweight, efficient wrappers over the DB clients making use of indexes and native TTLs where available. -- [keyv-mongo]() – MongoDB storage adapter for Keyv. -- [keyv-mysql]() – MySQL/MariaDB storage adapter for Keyv. -- [keyv-postgres]() – PostgreSQL storage adapter for Keyv. -- [keyv-redis]() – Redis storage adapter for Keyv. -- [keyv-sqlite]() – SQLite storage adapter for Keyv. +- [@keyvhq/mongo](/packages/mongo) – MongoDB storage adapter for Keyv. +- [@keyvhq/mysql](/packages/mysql) – MySQL/MariaDB storage adapter for Keyv. +- [@keyvhq/postgres](/packages/postgres) – PostgreSQL storage adapter for Keyv. +- [@keyvhq/redis](/packages/redis) – Redis storage adapter for Keyv. +- [@keyvhq/sqlite](/packages/sqlite) – SQLite storage adapter for Keyv. ### Community storage adapters diff --git a/packages/keyv/CHANGELOG.md b/packages/core/CHANGELOG.md similarity index 100% rename from packages/keyv/CHANGELOG.md rename to packages/core/CHANGELOG.md diff --git a/packages/keyv/package.json b/packages/core/package.json similarity index 100% rename from packages/keyv/package.json rename to packages/core/package.json diff --git a/packages/keyv/src/index.js b/packages/core/src/index.js similarity index 100% rename from packages/keyv/src/index.js rename to packages/core/src/index.js diff --git a/packages/keyv/test/keyv.js b/packages/core/test/keyv.js similarity index 100% rename from packages/keyv/test/keyv.js rename to packages/core/test/keyv.js diff --git a/packages/keyv-mongo/README.md b/packages/keyv-mongo/README.md deleted file mode 100644 index 7cc2ddc..0000000 --- a/packages/keyv-mongo/README.md +++ /dev/null @@ -1,39 +0,0 @@ -# @keyv/mongo [keyv](https://github.com/lukechilds/keyv) - -> MongoDB storage adapter for Keyv - -[![Build Status](https://travis-ci.org/lukechilds/keyv-mongo.svg?branch=master)](https://travis-ci.org/lukechilds/keyv-mongo) -[![Coverage Status](https://coveralls.io/repos/github/lukechilds/keyv-mongo/badge.svg?branch=master)](https://coveralls.io/github/lukechilds/keyv-mongo?branch=master) -[![npm](https://img.shields.io/npm/v/@keyv/mongo.svg)](https://www.npmjs.com/package/@keyv/mongo) - -MongoDB storage adapter for [Keyv](https://github.com/lukechilds/keyv). - -Uses TTL indexes to automatically remove expired documents. However [MongoDB doesn't guarantee data will be deleted immediately upon expiration](https://docs.mongodb.com/manual/core/index-ttl/#timing-of-the-delete-operation), so expiry dates are revalidated in Keyv. - -## Install - -```shell -npm install --save keyv @keyv/mongo -``` - -## Usage - -```js -const Keyv = require('keyv') - -const keyv = new Keyv('mongodb://user:pass@localhost:27017/dbname') -keyv.on('error', handleConnectionError) -``` - -You can specify the collection name, by default `'keyv'` is used. - -e.g: - -```js -const keyv = new Keyv('mongodb://user:pass@localhost:27017/dbname', { collection: 'cache' }) -``` - -## License - -**keyv** © [Luke Childs](https://github.com/lukechilds), Released under the [MIT](/LICENSE.md) License.
-Maintained by [Kiko Beats](https://kikobeats.com) and [Jytesh](https://github.com/Jytesh), with help from [contributors](https://github.com/microlinkhq/keyv/contributors). diff --git a/packages/keyv-mysql/README.md b/packages/keyv-mysql/README.md deleted file mode 100644 index 4d97a53..0000000 --- a/packages/keyv-mysql/README.md +++ /dev/null @@ -1,42 +0,0 @@ -# @keyv/mysql [keyv](https://github.com/lukechilds/keyv) - -> MySQL/MariaDB storage adapter for Keyv - -[![Build Status](https://travis-ci.org/lukechilds/keyv-mysql.svg?branch=master)](https://travis-ci.org/lukechilds/keyv-mysql) -[![Coverage Status](https://coveralls.io/repos/github/lukechilds/keyv-mysql/badge.svg?branch=master)](https://coveralls.io/github/lukechilds/keyv-mysql?branch=master) -[![npm](https://img.shields.io/npm/v/@keyv/mysql.svg)](https://www.npmjs.com/package/@keyv/mysql) - -MySQL/MariaDB storage adapter for [Keyv](https://github.com/lukechilds/keyv). - -## Install - -```shell -npm install --save keyv @keyv/mysql -``` - -## 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 -}) -``` - -**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. [#5](https://github.com/lukechilds/keyv-sql/issues/5) - -## License - -**keyv** © [Luke Childs](https://github.com/lukechilds), Released under the [MIT](/LICENSE.md) License.
-Maintained by [Kiko Beats](https://kikobeats.com) and [Jytesh](https://github.com/Jytesh), with help from [contributors](https://github.com/microlinkhq/keyv/contributors). diff --git a/packages/keyv-postgres/README.md b/packages/keyv-postgres/README.md deleted file mode 100644 index f02f478..0000000 --- a/packages/keyv-postgres/README.md +++ /dev/null @@ -1,39 +0,0 @@ -# @keyv/postgres [keyv](https://github.com/lukechilds/keyv) - -> PostgreSQL storage adapter for Keyv - -[![Build Status](https://travis-ci.org/lukechilds/keyv-postgres.svg?branch=master)](https://travis-ci.org/lukechilds/keyv-postgres) -[![Coverage Status](https://coveralls.io/repos/github/lukechilds/keyv-postgres/badge.svg?branch=master)](https://coveralls.io/github/lukechilds/keyv-postgres?branch=master) -[![npm](https://img.shields.io/npm/v/@keyv/postgres.svg)](https://www.npmjs.com/package/@keyv/postgres) - -PostgreSQL storage adapter for [Keyv](https://github.com/lukechilds/keyv). - -Requires Postgres 9.5 or newer for `ON CONFLICT` support to allow performant upserts. [Why?](https://stackoverflow.com/questions/17267417/how-to-upsert-merge-insert-on-duplicate-update-in-postgresql/17267423#17267423) - -## Install - -```shell -npm install --save keyv @keyv/postgres -``` - -## Usage - -```js -const Keyv = require('keyv') - -const keyv = new Keyv('postgresql://user:pass@localhost:5432/dbname') -keyv.on('error', handleConnectionError) -``` - -You can specify the `table` option. - -e.g: - -```js -const keyv = new Keyv('postgresql://user:pass@localhost:5432/dbname', { table: 'cache' }) -``` - -## License - -**keyv** © [Luke Childs](https://github.com/lukechilds), Released under the [MIT](/LICENSE.md) License.
-Maintained by [Kiko Beats](https://kikobeats.com) and [Jytesh](https://github.com/Jytesh), with help from [contributors](https://github.com/microlinkhq/keyv/contributors). diff --git a/packages/keyv-sql/README.md b/packages/keyv-sql/README.md deleted file mode 100644 index e474040..0000000 --- a/packages/keyv-sql/README.md +++ /dev/null @@ -1,18 +0,0 @@ -# @keyv/sql [keyv](https://github.com/lukechilds/keyv) - -> Parent class for SQL based Keyv storage adapters - -[![Build Status](https://travis-ci.org/lukechilds/keyv-sql.svg?branch=master)](https://travis-ci.org/lukechilds/keyv-sql) -[![Coverage Status](https://coveralls.io/repos/github/lukechilds/keyv-sql/badge.svg?branch=master)](https://coveralls.io/github/lukechilds/keyv-sql?branch=master) -[![npm](https://img.shields.io/npm/v/@keyv/sql.svg)](https://www.npmjs.com/package/@keyv/sql) - -Parent class containing the common logic for SQL based Keyv storage adapters: - -- [`keyv-sqlite`](https://github.com/lukechilds/keyv-sqlite) -- [`keyv-postgres`](https://github.com/lukechilds/keyv-postgres) -- [`keyv-mysql`](https://github.com/lukechilds/keyv-mysql) - -## License - -**keyv** © [Luke Childs](https://github.com/lukechilds), Released under the [MIT](/LICENSE.md) License.
-Maintained by [Kiko Beats](https://kikobeats.com) and [Jytesh](https://github.com/Jytesh), with help from [contributors](https://github.com/microlinkhq/keyv/contributors). diff --git a/packages/keyv-sqlite/README.md b/packages/keyv-sqlite/README.md deleted file mode 100644 index 5022738..0000000 --- a/packages/keyv-sqlite/README.md +++ /dev/null @@ -1,40 +0,0 @@ -# @keyv/sqlite [keyv](https://github.com/lukechilds/keyv) - -> SQLite storage adapter for Keyv - -[![Build Status](https://travis-ci.org/lukechilds/keyv-sqlite.svg?branch=master)](https://travis-ci.org/lukechilds/keyv-sqlite) -[![Coverage Status](https://coveralls.io/repos/github/lukechilds/keyv-sqlite/badge.svg?branch=master)](https://coveralls.io/github/lukechilds/keyv-sqlite?branch=master) -[![npm](https://img.shields.io/npm/v/@keyv/sqlite.svg)](https://www.npmjs.com/package/@keyv/sqlite) - -SQLite storage adapter for [Keyv](https://github.com/lukechilds/keyv). - -## Install - -```shell -npm install --save keyv @keyv/sqlite -``` - -## Usage - -```js -const Keyv = require('keyv') - -const keyv = new Keyv('sqlite://path/to/database.sqlite') -keyv.on('error', handleConnectionError) -``` - -You can specify the `table` and [`busyTimeout`](https://sqlite.org/c3ref/busy_timeout.html) option. - -e.g: - -```js -const keyv = new Keyv('sqlite://path/to/database.sqlite', { - table: 'cache', - busyTimeout: 10000 -}) -``` - -## License - -**keyv** © [Luke Childs](https://github.com/lukechilds), Released under the [MIT](/LICENSE.md) License.
-Maintained by [Kiko Beats](https://kikobeats.com) and [Jytesh](https://github.com/Jytesh), with help from [contributors](https://github.com/microlinkhq/keyv/contributors). diff --git a/packages/keyv-test-suite/README.md b/packages/keyv-test-suite/README.md deleted file mode 100644 index 2b065d8..0000000 --- a/packages/keyv-test-suite/README.md +++ /dev/null @@ -1,68 +0,0 @@ -# @keyv/test-suite [keyv](https://github.com/lukechilds/keyv) - -> Test suite for Keyv API compliance - -[![Build Status](https://travis-ci.org/lukechilds/keyv-test-suite.svg?branch=master)](https://travis-ci.org/lukechilds/keyv-test-suite) -[![Coverage Status](https://coveralls.io/repos/github/lukechilds/keyv-test-suite/badge.svg?branch=master)](https://coveralls.io/github/lukechilds/keyv-test-suite?branch=master) -[![npm](https://img.shields.io/npm/v/@keyv/test-suite.svg)](https://www.npmjs.com/package/@keyv/test-suite) - -Complete [AVA](https://github.com/avajs/ava) test suite to test a [Keyv](https://github.com/lukechilds/keyv) storage adapter for API compliance. - -## Usage - -### Install - -Install AVA, Keyv and `@keyv/test-suite` as development dependencies. - -```shell -npm install --save-dev ava keyv @keyv/test-suite -``` - -Then update `keyv` and `@keyv/test-suite` versions to `*` in `package.json` to ensure you're always testing against the latest version. - -### Create Test File - -`test.js` - -```js -import test from 'ava' -import keyvTestSuite from '@keyv/test-suite' -import Keyv from 'keyv' -import KeyvStore from './' - -const store = () => new KeyvStore() -keyvTestSuite(test, Keyv, store) -``` - -Where `KeyvStore` is your storage adapter. - -Set your test script in `package.json` to `ava`. -```json -"scripts": { - "test": "ava" -} -``` - -### Test on Active Node.js LTS and Higher - -An example configuration for Travis CI would look like this: - -`.travis.yml` - -```yaml -language: node_js -node_js: - - '8' - - '6' - - '4' -script: npm test -``` - -## Example - -Take a look at [keyv-redis](https://github.com/lukechilds/keyv-redis) for an example of an existing storage adapter using `@keyv/test-suite`. - -## License - -**keyv** © [Luke Childs](https://github.com/lukechilds), Released under the [MIT](/LICENSE.md) License.
-Maintained by [Kiko Beats](https://kikobeats.com) and [Jytesh](https://github.com/Jytesh), with help from [contributors](https://github.com/microlinkhq/keyv/contributors). diff --git a/packages/keyv/README.md b/packages/keyv/README.md deleted file mode 100644 index c46527c..0000000 --- a/packages/keyv/README.md +++ /dev/null @@ -1,296 +0,0 @@ -

- keyv -
-
-

- -> Simple key-value storage with support for multiple backends - -[![Build Status](https://travis-ci.org/lukechilds/keyv.svg?branch=master)](https://travis-ci.org/lukechilds/keyv) -[![Coverage Status](https://coveralls.io/repos/github/lukechilds/keyv/badge.svg?branch=master)](https://coveralls.io/github/lukechilds/keyv?branch=master) -[![npm](https://img.shields.io/npm/dm/keyv.svg)](https://www.npmjs.com/package/keyv) -[![npm](https://img.shields.io/npm/v/keyv.svg)](https://www.npmjs.com/package/keyv) - -Keyv provides a consistent interface for key-value storage across multiple backends via storage adapters. It supports TTL based expiry, making it suitable as a cache or a persistent key-value store. - -## Features - -There are a few existing modules similar to Keyv, however Keyv is different because it: - -- Isn't bloated -- Has a simple Promise based API -- Suitable as a TTL based cache or persistent key-value store -- [Easily embeddable](#add-cache-support-to-your-module) inside another module -- Works with any storage that implements the [`Map`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map) API -- Handles all JSON types plus `Buffer` -- Supports namespaces -- Wide range of [**efficient, well tested**](#official-storage-adapters) storage adapters -- Connection errors are passed through (db failures won't kill your app) -- Supports the current active LTS version of Node.js or higher - -## Usage - -Install Keyv. - -``` -npm install --save keyv -``` - -By default everything is stored in memory, you can optionally also install a storage adapter. - -``` -npm install --save @keyv/redis -npm install --save @keyv/mongo -npm install --save @keyv/sqlite -npm install --save @keyv/postgres -npm install --save @keyv/mysql -``` - -Create a new Keyv instance, passing your connection string if applicable. Keyv will automatically load the correct storage adapter. - -```js -const Keyv = require('keyv'); - -// One of the following -const keyv = new Keyv(); -const keyv = new Keyv('redis://user:pass@localhost:6379'); -const keyv = new Keyv('mongodb://user:pass@localhost:27017/dbname'); -const keyv = new Keyv('sqlite://path/to/database.sqlite'); -const keyv = new Keyv('postgresql://user:pass@localhost:5432/dbname'); -const keyv = new Keyv('mysql://user:pass@localhost:3306/dbname'); - -// Handle DB connection errors -keyv.on('error', err => console.log('Connection Error', err)); - -await keyv.set('foo', 'expires in 1 second', 1000); // true -await keyv.set('foo', 'never expires'); // true -await keyv.get('foo'); // 'never expires' -await keyv.delete('foo'); // true -await keyv.clear(); // undefined -``` - -### Namespaces - -You can namespace your Keyv instance to avoid key collisions and allow you to clear only a certain namespace while using the same database. - -```js -const users = new Keyv('redis://user:pass@localhost:6379', { namespace: 'users' }); -const cache = new Keyv('redis://user:pass@localhost:6379', { namespace: 'cache' }); - -await users.set('foo', 'users'); // true -await cache.set('foo', 'cache'); // true -await users.get('foo'); // 'users' -await cache.get('foo'); // 'cache' -await users.clear(); // undefined -await users.get('foo'); // undefined -await cache.get('foo'); // 'cache' -``` - -### Custom Serializers - -Keyv uses [`json-buffer`](https://github.com/dominictarr/json-buffer) for data serialization to ensure consistency across different backends. - -You can optionally provide your own serialization functions to support extra data types or to serialize to something other than JSON. - -```js -const keyv = new Keyv({ serialize: JSON.stringify, deserialize: JSON.parse }) -``` - -**Warning:** Using custom serializers means you lose any guarantee of data consistency. You should do extensive testing with your serialisation functions and chosen storage engine. - -## Official Storage Adapters - -The official storage adapters are covered by [over 150 integration tests](https://travis-ci.org/lukechilds/keyv/jobs/260418145) to guarantee consistent behaviour. They are lightweight, efficient wrappers over the DB clients making use of indexes and native TTLs where available. - -Database | Adapter | Native TTL | Status ----|---|---|--- -Redis | [@keyv/redis](https://github.com/lukechilds/keyv-redis) | Yes | [![Build Status](https://travis-ci.org/lukechilds/keyv-redis.svg?branch=master)](https://travis-ci.org/lukechilds/keyv-redis) [![Coverage Status](https://coveralls.io/repos/github/lukechilds/keyv-redis/badge.svg?branch=master)](https://coveralls.io/github/lukechilds/keyv-redis?branch=master) -MongoDB | [@keyv/mongo](https://github.com/lukechilds/keyv-mongo) | Yes | [![Build Status](https://travis-ci.org/lukechilds/keyv-mongo.svg?branch=master)](https://travis-ci.org/lukechilds/keyv-mongo) [![Coverage Status](https://coveralls.io/repos/github/lukechilds/keyv-mongo/badge.svg?branch=master)](https://coveralls.io/github/lukechilds/keyv-mongo?branch=master) -SQLite | [@keyv/sqlite](https://github.com/lukechilds/keyv-sqlite) | No | [![Build Status](https://travis-ci.org/lukechilds/keyv-sqlite.svg?branch=master)](https://travis-ci.org/lukechilds/keyv-sqlite) [![Coverage Status](https://coveralls.io/repos/github/lukechilds/keyv-sqlite/badge.svg?branch=master)](https://coveralls.io/github/lukechilds/keyv-sqlite?branch=master) -PostgreSQL | [@keyv/postgres](https://github.com/lukechilds/keyv-postgres) | No | [![Build Status](https://travis-ci.org/lukechilds/keyv-postgres.svg?branch=master)](https://travis-ci.org/lukechildskeyv-postgreskeyv) [![Coverage Status](https://coveralls.io/repos/github/lukechilds/keyv-postgres/badge.svg?branch=master)](https://coveralls.io/github/lukechilds/keyv-postgres?branch=master) -MySQL | [@keyv/mysql](https://github.com/lukechilds/keyv-mysql) | No | [![Build Status](https://travis-ci.org/lukechilds/keyv-mysql.svg?branch=master)](https://travis-ci.org/lukechilds/keyv-mysql) [![Coverage Status](https://coveralls.io/repos/github/lukechilds/keyv-mysql/badge.svg?branch=master)](https://coveralls.io/github/lukechilds/keyv-mysql?branch=master) - -## Third-party Storage Adapters - -You can also use third-party storage adapters or build your own. Keyv will wrap these storage adapters in TTL functionality and handle complex types internally. - -```js -const Keyv = require('keyv') -const myAdapter = require('./my-storage-adapter') - -const keyv = new Keyv({ store: myAdapter }) -``` - -Any store that follows the [`Map`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map) api will work. - -```js -new Keyv({ store: new Map() }) -``` - -For example, [`quick-lru`](https://github.com/sindresorhus/quick-lru) is a completely unrelated module that implements the Map API. - -```js -const Keyv = require('keyv') -const QuickLRU = require('quick-lru') - -const lru = new QuickLRU({ maxSize: 1000 }) -const keyv = new Keyv({ store: lru }) -``` - -The following are third-party storage adapters compatible with Keyv: - -- [quick-lru](https://github.com/sindresorhus/quick-lru) - Simple "Least Recently Used" (LRU) cache -- [keyv-file](https://github.com/zaaack/keyv-file) - File system storage adapter for Keyv -- [keyv-dynamodb](https://www.npmjs.com/package/keyv-dynamodb) - DynamoDB storage adapter for Keyv -- [keyv-firestore ](https://github.com/goto-bus-stop/keyv-firestore) – Firebase Cloud Firestore adapter for Keyv -- [keyv-mssql](https://github.com/pmorgan3/keyv-mssql) - Microsoft Sql Server adapter for Keyv -- [keyv-memcache](https://github.com/jaredwray/keyv-memcache) - Memcache storage adapter for Keyv - -## Add Cache Support to your Module - -Keyv is designed to be easily embedded into other modules to add cache support. The recommended pattern is to expose a `cache` option in your modules options which is passed through to Keyv. Caching will work in memory by default and users have the option to also install a Keyv storage adapter and pass in a connection string, or any other storage that implements the `Map` API. - -You should also set a namespace for your module so you can safely call `.clear()` without clearing unrelated app data. - -Inside your module: - -```js -class AwesomeModule { - constructor (opts) { - this.cache = new Keyv({ - uri: typeof opts.cache === 'string' && opts.cache, - store: typeof opts.cache !== 'string' && opts.cache, - namespace: 'awesome-module' - }) - } -} -``` - -Now it can be consumed like this: - -```js -const AwesomeModule = require('awesome-module'); - -// Caches stuff in memory by default -const awesomeModule = new AwesomeModule(); - -// After npm install --save keyv-redis -const awesomeModule = new AwesomeModule({ cache: 'redis://localhost' }); - -// Some third-party module that implements the Map API -const awesomeModule = new AwesomeModule({ cache: some3rdPartyStore }); -``` - -## API - -### new Keyv([uri], [options]) - -Returns a new Keyv instance. - -The Keyv instance is also an `EventEmitter` that will emit an `'error'` event if the storage adapter connection fails. - -### uri - -Type: `String`
-Default: `undefined` - -The connection string URI. - -Merged into the options object as options.uri. - -### options - -Type: `Object` - -The options object is also passed through to the storage adapter. Check your storage adapter docs for any extra options. - -#### options.namespace - -Type: `String`
-Default: `'keyv'` - -Namespace for the current instance. - -#### options.ttl - -Type: `Number`
-Default: `undefined` - -Default TTL. Can be overridden by specififying a TTL on `.set()`. - -#### options.serialize - -Type: `Function`
-Default: `JSONB.stringify` - -A custom serialization function. - -#### options.deserialize - -Type: `Function`
-Default: `JSONB.parse` - -A custom deserialization function. - -#### options.emitErrors - -Type: `Boolean`
-Default: `true` - -When it's `true`, errors on `options.store` will be emitted at keyv level. - -#### options.store - -Type: `Storage adapter instance`
-Default: `new Map()` - -The storage adapter instance to be used by Keyv. - -#### options.adapter - -Type: `String`
-Default: `undefined` - -Specify an adapter to use. e.g `'redis'` or `'mongodb'`. - -### Instance - -Keys must always be strings. Values can be of any type. - -#### .set(key, value, [ttl]) - -Set a value. - -By default keys are persistent. You can set an expiry TTL in milliseconds. - -Returns a promise which resolves to `true`. - -#### .get(key, [options]) - -Returns a promise which resolves to the retrieved value. - -##### options.raw - -Type: `Boolean`
-Default: `false` - -If set to true the raw DB object Keyv stores internally will be returned instead of just the value. - -This contains the TTL timestamp. - -#### .delete(key) - -Deletes an entry. - -Returns a promise which resolves to `true` if the key existed, `false` if not. - -#### .clear() - -Delete all entries in the current namespace. - -Returns a promise which is resolved when the entries have been cleared. - -## License - -**keyv** © [Luke Childs](https://github.com/lukechilds), Released under the [MIT](/LICENSE.md) License.
-Maintained by [Kiko Beats](https://kikobeats.com) and [Jytesh](https://github.com/Jytesh), with help from [contributors](https://github.com/microlinkhq/keyv/contributors). diff --git a/packages/keyv-mongo/CHANGELOG.md b/packages/mongo/CHANGELOG.md similarity index 100% rename from packages/keyv-mongo/CHANGELOG.md rename to packages/mongo/CHANGELOG.md diff --git a/packages/mongo/README.md b/packages/mongo/README.md new file mode 100644 index 0000000..606e2a5 --- /dev/null +++ b/packages/mongo/README.md @@ -0,0 +1,35 @@ +# @keyv/mongo [keyv](https://github.com/microlinkhq/keyv) + +> MongoDB storage adapter for [Keyv](https://github.com/microlinkhq/keyv). + +Uses TTL indexes to automatically remove expired documents. However [MongoDB doesn't guarantee data will be deleted immediately upon expiration](https://docs.mongodb.com/manual/core/index-ttl/#timing-of-the-delete-operation), so expiry dates are revalidated in Keyv. + +## Install + +```shell +npm install --save keyv @keyv/mongo +``` + +## Usage + +```js +const Keyv = require('keyv') + +const keyv = new Keyv('mongodb://user:pass@localhost:27017/dbname') +keyv.on('error', handleConnectionError) +``` + +You can specify the collection name, by default `'keyv'` is used. + +e.g: + +```js +const keyv = new Keyv('mongodb://user:pass@localhost:27017/dbname', { collection: 'cache' }) +``` + +## License + +**@keyvhq/mongo** © [Microlink](https://microlink.io), Released under the [MIT](https://github.com/microlinkhq/keyv/blob/master/LICENSE.md) License.
+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) diff --git a/packages/keyv-mongo/package.json b/packages/mongo/package.json similarity index 96% rename from packages/keyv-mongo/package.json rename to packages/mongo/package.json index 0d81f6c..c633b06 100644 --- a/packages/keyv-mongo/package.json +++ b/packages/mongo/package.json @@ -10,7 +10,7 @@ "url": "https://microlink.io" }, "repository": { - "directory": "packages/keyv-mongo", + "directory": "packages/mongo", "type": "git", "url": "git+https://github.com/microlinkhq/keyv.git" }, diff --git a/packages/keyv-mongo/src/index.js b/packages/mongo/src/index.js similarity index 100% rename from packages/keyv-mongo/src/index.js rename to packages/mongo/src/index.js diff --git a/packages/keyv-mongo/test/index.js b/packages/mongo/test/index.js similarity index 100% rename from packages/keyv-mongo/test/index.js rename to packages/mongo/test/index.js diff --git a/packages/keyv-mysql/CHANGELOG.md b/packages/mysql/CHANGELOG.md similarity index 100% rename from packages/keyv-mysql/CHANGELOG.md rename to packages/mysql/CHANGELOG.md diff --git a/packages/mysql/README.md b/packages/mysql/README.md new file mode 100644 index 0000000..8da8fd0 --- /dev/null +++ b/packages/mysql/README.md @@ -0,0 +1,38 @@ +# @keyv/mysql [keyv](https://github.com/microlinkhq/keyv) + +> MySQL/MariaDB storage adapter for [Keyv](https://github.com/microlinkhq/keyv). + +## Install + +```shell +npm install --save keyv @keyv/mysql +``` + +## 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 +}) +``` + +**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. [#5](https://github.com/microlinkhq/sql/issues/5) + +## License + +**@keyvhq/mysql** © [Microlink](https://microlink.io), Released under the [MIT](https://github.com/microlinkhq/keyv/blob/master/LICENSE.md) License.
+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) diff --git a/packages/keyv-mysql/package.json b/packages/mysql/package.json similarity index 100% rename from packages/keyv-mysql/package.json rename to packages/mysql/package.json diff --git a/packages/keyv-mysql/src/index.js b/packages/mysql/src/index.js similarity index 100% rename from packages/keyv-mysql/src/index.js rename to packages/mysql/src/index.js diff --git a/packages/keyv-mysql/test/index.js b/packages/mysql/test/index.js similarity index 100% rename from packages/keyv-mysql/test/index.js rename to packages/mysql/test/index.js diff --git a/packages/keyv-postgres/CHANGELOG.md b/packages/postgres/CHANGELOG.md similarity index 100% rename from packages/keyv-postgres/CHANGELOG.md rename to packages/postgres/CHANGELOG.md diff --git a/packages/postgres/README.md b/packages/postgres/README.md new file mode 100644 index 0000000..3e4ff4e --- /dev/null +++ b/packages/postgres/README.md @@ -0,0 +1,35 @@ +# @keyv/postgres [keyv](https://github.com/microlinkhq/keyv) + +> PostgreSQL storage adapter for [Keyv](https://github.com/microlinkhq/keyv). + +Requires Postgres 9.5 or newer for `ON CONFLICT` support to allow performant upserts. [Why?](https://stackoverflow.com/questions/17267417/how-to-upsert-merge-insert-on-duplicate-update-in-postgresql/17267423#17267423) + +## Install + +```shell +npm install --save keyv @keyv/postgres +``` + +## Usage + +```js +const Keyv = require('keyv') + +const keyv = new Keyv('postgresql://user:pass@localhost:5432/dbname') +keyv.on('error', handleConnectionError) +``` + +You can specify the `table` option. + +e.g: + +```js +const keyv = new Keyv('postgresql://user:pass@localhost:5432/dbname', { table: 'cache' }) +``` + +## License + +**@keyvhq/postgres** © [Microlink](https://microlink.io), Released under the [MIT](https://github.com/microlinkhq/keyv/blob/master/LICENSE.md) License.
+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) diff --git a/packages/keyv-postgres/package.json b/packages/postgres/package.json similarity index 100% rename from packages/keyv-postgres/package.json rename to packages/postgres/package.json diff --git a/packages/keyv-postgres/src/index.js b/packages/postgres/src/index.js similarity index 100% rename from packages/keyv-postgres/src/index.js rename to packages/postgres/src/index.js diff --git a/packages/keyv-postgres/test/index.js b/packages/postgres/test/index.js similarity index 100% rename from packages/keyv-postgres/test/index.js rename to packages/postgres/test/index.js diff --git a/packages/keyv-redis/CHANGELOG.md b/packages/redis/CHANGELOG.md similarity index 100% rename from packages/keyv-redis/CHANGELOG.md rename to packages/redis/CHANGELOG.md diff --git a/packages/keyv-redis/Dockerfile b/packages/redis/Dockerfile similarity index 100% rename from packages/keyv-redis/Dockerfile rename to packages/redis/Dockerfile diff --git a/packages/keyv-redis/README.md b/packages/redis/README.md similarity index 54% rename from packages/keyv-redis/README.md rename to packages/redis/README.md index 878a489..950d5fd 100644 --- a/packages/keyv-redis/README.md +++ b/packages/redis/README.md @@ -1,12 +1,6 @@ -# @keyv/redis [keyv](https://github.com/lukechilds/keyv) +# @keyv/redis [keyv](https://github.com/microlinkhq/keyv) -> Redis storage adapter for Keyv - -[![Build Status](https://travis-ci.org/lukechilds/keyv-redis.svg?branch=master)](https://travis-ci.org/lukechilds/keyv-redis) -[![Coverage Status](https://coveralls.io/repos/github/lukechilds/keyv-redis/badge.svg?branch=master)](https://coveralls.io/github/lukechilds/keyv-redis?branch=master) -[![npm](https://img.shields.io/npm/v/@keyv/redis.svg)](https://www.npmjs.com/package/@keyv/redis) - -Redis storage adapter for [Keyv](https://github.com/lukechilds/keyv). +> Redis storage adapter for [Keyv](https://github.com/microlinkhq/keyv). TTL functionality is handled directly by Redis so no timestamps are stored and expired keys are cleaned up internally. @@ -57,5 +51,7 @@ const keyv = new Keyv({ store: keyvRedis }) ## License -**keyv** © [Luke Childs](https://github.com/lukechilds), Released under the [MIT](/LICENSE.md) License.
-Maintained by [Kiko Beats](https://kikobeats.com) and [Jytesh](https://github.com/Jytesh), with help from [contributors](https://github.com/microlinkhq/keyv/contributors). +**@keyvhq/redis** © [Microlink](https://microlink.io), Released under the [MIT](https://github.com/microlinkhq/keyv/blob/master/LICENSE.md) License.
+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) diff --git a/packages/keyv-redis/docker-compose.yml b/packages/redis/docker-compose.yml similarity index 100% rename from packages/keyv-redis/docker-compose.yml rename to packages/redis/docker-compose.yml diff --git a/packages/keyv-redis/package.json b/packages/redis/package.json similarity index 96% rename from packages/keyv-redis/package.json rename to packages/redis/package.json index ad91cbb..0209617 100644 --- a/packages/keyv-redis/package.json +++ b/packages/redis/package.json @@ -10,7 +10,7 @@ "url": "https://microlink.io" }, "repository": { - "directory": "packages/keyv-redis", + "directory": "packages/redis", "type": "git", "url": "git+https://github.com/microlinkhq/keyv.git" }, diff --git a/packages/keyv-redis/src/index.js b/packages/redis/src/index.js similarity index 100% rename from packages/keyv-redis/src/index.js rename to packages/redis/src/index.js diff --git a/packages/keyv-redis/test/index.js b/packages/redis/test/index.js similarity index 100% rename from packages/keyv-redis/test/index.js rename to packages/redis/test/index.js diff --git a/packages/keyv-sql/CHANGELOG.md b/packages/sql/CHANGELOG.md similarity index 100% rename from packages/keyv-sql/CHANGELOG.md rename to packages/sql/CHANGELOG.md diff --git a/packages/sql/README.md b/packages/sql/README.md new file mode 100644 index 0000000..a91acda --- /dev/null +++ b/packages/sql/README.md @@ -0,0 +1,14 @@ +# @keyv/sql [keyv](https://github.com/microlinkhq/keyv) + +Parent class containing the common logic for SQL based Keyv storage adapters: + +- [`@keyv/sqlite`](https://github.com/microlinkhq/packageS/sqlite) +- [`@keyv/postgres`](https://github.com/microlinkhq/packageS/postgres) +- [`@keyv/mysql`](https://github.com/microlinkhq/packageS/mysql) + +## License + +**@keyvhq/sql** © [Microlink](https://microlink.io), Released under the [MIT](https://github.com/microlinkhq/keyv/blob/master/LICENSE.md) License.
+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) diff --git a/packages/keyv-sql/package.json b/packages/sql/package.json similarity index 96% rename from packages/keyv-sql/package.json rename to packages/sql/package.json index 76078f6..c136961 100644 --- a/packages/keyv-sql/package.json +++ b/packages/sql/package.json @@ -10,7 +10,7 @@ "url": "https://microlink.io" }, "repository": { - "directory": "packages/keyv-sql", + "directory": "packages/sql", "type": "git", "url": "git+https://github.com/microlinkhq/keyv.git" }, diff --git a/packages/keyv-sql/src/index.js b/packages/sql/src/index.js similarity index 100% rename from packages/keyv-sql/src/index.js rename to packages/sql/src/index.js diff --git a/packages/keyv-sql/test/index.js b/packages/sql/test/index.js similarity index 100% rename from packages/keyv-sql/test/index.js rename to packages/sql/test/index.js diff --git a/packages/keyv-sqlite/CHANGELOG.md b/packages/sqlite/CHANGELOG.md similarity index 100% rename from packages/keyv-sqlite/CHANGELOG.md rename to packages/sqlite/CHANGELOG.md diff --git a/packages/sqlite/README.md b/packages/sqlite/README.md new file mode 100644 index 0000000..2d9de75 --- /dev/null +++ b/packages/sqlite/README.md @@ -0,0 +1,36 @@ +# @keyv/sqlite [keyv](https://github.com/microlinkhq/keyv) + +SQLite storage adapter for [Keyv](https://github.com/microlinkhq/keyv). + +## Install + +```shell +npm install --save keyv @keyv/sqlite +``` + +## Usage + +```js +const Keyv = require('keyv') + +const keyv = new Keyv('sqlite://path/to/database.sqlite') +keyv.on('error', handleConnectionError) +``` + +You can specify the `table` and [`busyTimeout`](https://sqlite.org/c3ref/busy_timeout.html) option. + +e.g: + +```js +const keyv = new Keyv('sqlite://path/to/database.sqlite', { + table: 'cache', + busyTimeout: 10000 +}) +``` + +## License + +**@keyvhq/sqlite** © [Microlink](https://microlink.io), Released under the [MIT](https://github.com/microlinkhq/keyv/blob/master/LICENSE.md) License.
+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) diff --git a/packages/keyv-sqlite/package.json b/packages/sqlite/package.json similarity index 96% rename from packages/keyv-sqlite/package.json rename to packages/sqlite/package.json index 12af4fa..2f300ae 100644 --- a/packages/keyv-sqlite/package.json +++ b/packages/sqlite/package.json @@ -10,7 +10,7 @@ "url": "https://microlink.io" }, "repository": { - "directory": "packages/keyv-sqlite", + "directory": "packages/sqlite", "type": "git", "url": "git+https://github.com/microlinkhq/keyv.git" }, diff --git a/packages/keyv-sqlite/src/index.js b/packages/sqlite/src/index.js similarity index 100% rename from packages/keyv-sqlite/src/index.js rename to packages/sqlite/src/index.js diff --git a/packages/keyv-sqlite/test/index.js b/packages/sqlite/test/index.js similarity index 100% rename from packages/keyv-sqlite/test/index.js rename to packages/sqlite/test/index.js diff --git a/packages/keyv-test-suite/CHANGELOG.md b/packages/test-suite/CHANGELOG.md similarity index 100% rename from packages/keyv-test-suite/CHANGELOG.md rename to packages/test-suite/CHANGELOG.md diff --git a/packages/test-suite/README.md b/packages/test-suite/README.md new file mode 100644 index 0000000..89b986a --- /dev/null +++ b/packages/test-suite/README.md @@ -0,0 +1,64 @@ +# @keyv/test-suite [keyv](https://github.com/microlinkhq/keyv) + +Complete [AVA](https://github.com/avajs/ava) test suite to test a [Keyv](https://github.com/microlinkhq/keyv) storage adapter for API compliance. + +## Usage + +### Install + +Install AVA, Keyv and `@keyv/test-suite` as development dependencies. + +```shell +npm install --save-dev ava keyv @keyv/test-suite +``` + +Then update `keyv` and `@keyv/test-suite` versions to `*` in `package.json` to ensure you're always testing against the latest version. + +### Create Test File + +`test.js` + +```js +import test from 'ava' +import keyvTestSuite from '@keyv/test-suite' +import Keyv from 'keyv' +import KeyvStore from './' + +const store = () => new KeyvStore() +keyvTestSuite(test, Keyv, store) +``` + +Where `KeyvStore` is your storage adapter. + +Set your test script in `package.json` to `ava`. +```json +"scripts": { + "test": "ava" +} +``` + +### Test on Active Node.js LTS and Higher + +An example configuration for Travis CI would look like this: + +`.travis.yml` + +```yaml +language: node_js +node_js: + - '8' + - '6' + - '4' +script: npm test +``` + +## Example + +Take a look at [redis](https://github.com/microlinkhq/redis) for an example of an existing storage adapter using `@keyv/test-suite`. + +## License + +**@keyvhq/test-suite** © [Microlink](https://microlink.io), Released under the [MIT](https://github.com/microlinkhq/keyv/blob/master/LICENSE.md) License.
+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) diff --git a/packages/keyv-test-suite/package.json b/packages/test-suite/package.json similarity index 100% rename from packages/keyv-test-suite/package.json rename to packages/test-suite/package.json diff --git a/packages/keyv-test-suite/src/api.js b/packages/test-suite/src/api.js similarity index 100% rename from packages/keyv-test-suite/src/api.js rename to packages/test-suite/src/api.js diff --git a/packages/keyv-test-suite/src/index.js b/packages/test-suite/src/index.js similarity index 100% rename from packages/keyv-test-suite/src/index.js rename to packages/test-suite/src/index.js diff --git a/packages/keyv-test-suite/src/iteration.js b/packages/test-suite/src/iteration.js similarity index 100% rename from packages/keyv-test-suite/src/iteration.js rename to packages/test-suite/src/iteration.js diff --git a/packages/keyv-test-suite/src/namespace.js b/packages/test-suite/src/namespace.js similarity index 100% rename from packages/keyv-test-suite/src/namespace.js rename to packages/test-suite/src/namespace.js diff --git a/packages/keyv-test-suite/src/values.js b/packages/test-suite/src/values.js similarity index 100% rename from packages/keyv-test-suite/src/values.js rename to packages/test-suite/src/values.js