Skip to content

Commit

Permalink
Readme updates to support compression packages (#461)
Browse files Browse the repository at this point in the history
* readme updates to support compression packages

* fixing js issue

* removing extra code block

* removing old compression options

* updating gzip readme with correct package npm naming
  • Loading branch information
jaredwray authored Sep 1, 2022
1 parent f0ffa43 commit 13363a7
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 11 deletions.
8 changes: 4 additions & 4 deletions packages/compress-gzip/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
[![build](https://github.com/jaredwray/keyv/actions/workflows/tests.yaml/badge.svg)](https://github.com/jaredwray/keyv/actions/workflows/tests.yaml)
[![codecov](https://codecov.io/gh/jaredwray/keyv/branch/main/graph/badge.svg?token=bRzR3RyOXZ)](https://codecov.io/gh/jaredwray/keyv)
[![npm](https://img.shields.io/npm/v/@keyv/compress-brotli.svg)](https://www.npmjs.com/package/@keyv/compress-brotli)
[![npm](https://img.shields.io/npm/dm/@keyv/compress-brotli)](https://npmjs.com/package/@keyv/compress-brotli)
[![npm](https://img.shields.io/npm/v/@keyv/compress-gzip.svg)](https://www.npmjs.com/package/@keyv/compress-gzip)
[![npm](https://img.shields.io/npm/dm/@keyv/compress-gzip)](https://npmjs.com/package/@keyv/compress-gzip)

Gzip compression for [Keyv](https://github.com/jaredwray/keyv).

Expand All @@ -27,11 +27,11 @@ const keyv = new Keyv({store: new Map(), compression: new KeyvGzip()});

## API

### @keyv/compress-brotli(\[options])
### @keyv/compress-gzip(\[options])

#### options

All options for @keyv/compress-brotli are based on the package [compress-brotli](https://github.com/Kikobeats/compress-brotli)
All options for @keyv/compress-gzip are based on the package [compress-gzip](https://github.com/Rebsos/node-gzip#readme)

## License

Expand Down
29 changes: 22 additions & 7 deletions packages/keyv/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,20 @@ const awesomeModule = new AwesomeModule({ cache: 'redis://localhost' });
const awesomeModule = new AwesomeModule({ cache: some3rdPartyStore });
```

## Compression

Keyv supports `gzip` and `brotli` compression. To enable compression, pass the `compress` option to the constructor.

```js
const KeyvGzip = require('@keyv/compress-gzip');
const Keyv = require('keyv');

const keyvGzip = new KeyvGzip();;
const keyv = new Keyv({ compression: KeyvGzip });
```

You can also pass a custom compression function to the `compression` option. Following the pattern of the official compression adapters.

## API

### new Keyv([uri], [options])
Expand Down Expand Up @@ -224,6 +238,13 @@ Default: `undefined`

Default TTL. Can be overridden by specififying a TTL on `.set()`.

#### options.compression

Type: `@keyv/compress-<compression_package_name>`<br>
Default: `undefined`

Compression package to use. See [Compression](#compression) for more details.

#### options.serialize

Type: `Function`<br>
Expand Down Expand Up @@ -252,11 +273,6 @@ Default: `undefined`

Specify an adapter to use. e.g `'redis'` or `'mongodb'`.

#### options.compression

Type: `Compression instance`<br>
Default: `undefined`

### Instance

Keys must always be strings. Values can be of any type.
Expand Down Expand Up @@ -320,7 +336,6 @@ In this section of the documentation we will cover:
This package requires the following dependencies to run:

1) [Yarn V1](https://yarnpkg.com/getting-started/install)
2) [Lerna](https://lerna.js.org/)
3) [Docker](https://docs.docker.com/get-docker/)

## Setting up your workspace
Expand All @@ -342,7 +357,7 @@ Once the project is installed locally, you are ready to start up its services:

## Available Commands

Once the project is running, you can execute a variety of commands. The root workspace and each subpackage contain a `package.json` file with a `scripts` field listing all the commands that can be executed from that directory. This project also supports native `yarn`, `lerna`, and `docker` commands.
Once the project is running, you can execute a variety of commands. The root workspace and each subpackage contain a `package.json` file with a `scripts` field listing all the commands that can be executed from that directory. This project also supports native `yarn`, and `docker` commands.

Here, we'll cover the primary commands that can be executed from the root directory. Unless otherwise noted, these commands can also be executed from a subpackage. If executed from a subpackage, they will only affect that subpackage, rather than the entire workspace.

Expand Down

0 comments on commit 13363a7

Please sign in to comment.