https://github.com/gabel/keyv-nats
https://github.com/gabel/keyv-nats
cachios keyv nats typescript
Last synced: 19 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/gabel/keyv-nats
- Owner: gabel
- License: mit
- Created: 2023-05-31T07:12:23.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-01-30T15:16:14.000Z (over 1 year ago)
- Last Synced: 2024-08-09T07:29:22.470Z (10 months ago)
- Topics: cachios, keyv, nats, typescript
- Language: TypeScript
- Homepage:
- Size: 174 KB
- Stars: 1
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# keyv-nats
> NATS storage adapter for the awesome [keyv](https://github.com/jaredwray/keyv).
[](https://github.com/gabel/keyv-nats/actions/workflows/tests.yaml)
[](https://codecov.io/github/gabel/keyv-nats)
[](https://github.com/gabel/keyv-nats/blob/master/LICENSE)
[](https://npmjs.com/package/keyv-nats)## Installation
```shell
yarn add keyv keyv-nats
```## Usage
```typescript
import Keyv from 'keyv'
import KeyvNats from 'keyv-nats'const keyvNats = new KeyvNats({ servers: "localhost:4222" });
await keyvNats.connect();
const keyv = new Keyv({ store: keyvNats })const key = 'foo'
const value = 'bar'await keyv.set(key, value)
await keyv.get(key)
keyvNats.disconnect();
```## Tests
NATS Keyv storage adapter uses [Testcontainers for NodeJS](https://node.testcontainers.org/) in order to run
NATS server during test automation. Please check [general Docker requirements](https://www.testcontainers.org/supported_docker_environment/)
of Testcontainers to run those in your local docker environment.```shell
# nothing else required as testcontainer will start and stop nats
yarn test
```