# imc

> IMC is an In-Memory Cache key-value store.

Latest version **1.0.0** (published 2020-05-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install imc
pnpm add imc
yarn add imc
bun add imc
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2020-05-23 |
| First published | 2020-05-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 13.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Mark |
| Maintainers | remarkablemark |
| Keywords | imc, in-memory, cache, key-value, store |

## Links

- npm: https://www.npmjs.com/package/imc
- Repository: https://github.com/remarkablemark/imc
- Homepage: https://remarkablemark.org/imc/
- Issues: https://github.com/remarkablemark/imc
- npm.io page: https://npm.io/package/imc

## Alternatives

- [memory-cache](https://npm.io/package/memory-cache.md) — 795.0K weekly downloads
- [@httptoolkit/proxy-agent](https://npm.io/package/@httptoolkit/proxy-agent.md) — 11.2K weekly downloads
- [express-cache-controller](https://npm.io/package/express-cache-controller.md) — 5.3K weekly downloads
- [http-cache-middleware](https://npm.io/package/http-cache-middleware.md) — 4.5K weekly downloads
- [cache2](https://npm.io/package/cache2.md) — 1.5K weekly downloads

## Recent versions

- 1.0.0 (latest) — 2020-05-23
- 0.0.0 — 2020-05-22

## README

# IMC

[![NPM](https://nodei.co/npm/imc.png)](https://nodei.co/npm/imc/)

[![NPM version](https://img.shields.io/npm/v/imc.svg)](https://www.npmjs.com/package/imc)
[![Build Status](https://travis-ci.org/remarkablemark/imc.svg?branch=master)](https://travis-ci.org/remarkablemark/imc)
[![Coverage Status](https://coveralls.io/repos/github/remarkablemark/imc/badge.svg?branch=master)](https://coveralls.io/github/remarkablemark/imc?branch=master)

**IMC** is an **I**n-**M**emory **C**ache key-value store.

```js
import cache from 'imc';
cache.set('key', 'value');
cache.get('key'); // 'value'
```

## Installation

[NPM](https://www.npmjs.com/package/imc):

```sh
$ npm install imc --save
```

[Yarn](https://yarnpkg.com/package/imc):

```sh
$ yarn add imc
```

[CDN](https://unpkg.com/imc/):

```html
<script src="https://unpkg.com/imc@latest/umd/imc.min.js"></script>
<script>
  var cache = window.IMC.cache;
  var Cache = window.IMC.Cache;
</script>
```

## Usage

### Import Module

```js
// CommonJS
const { Cache, cache } = require('imc');

// ES Modules
import cache, { Cache } from 'imc';
```

### Global Cache

You can either use the global cache store:

```js
// cache is also a default export
import { cache } from 'imc';
```

### Local Cache

Or create a local cache store:

```js
import { Cache } from 'imc';
const cache = new Cache();
```

When instantiating a new cache store, the initial state can be set:

```js
const cache = new Cache({ key: 'value' });
```

### Set

Set key-value:

```js
cache.set('key', 'value');
```

Set key-value using object:

```js
cache.set({ key: 'value' });
```

Set multiple keys and values, which are merged to the store object:

```js
cache.set({
  key: 'value',
  answer: 42,
});
```

### Get

Get value from key:

```js
cache.get('key'); // 'value'
```

If key-value does not exist, it will return `undefined`:

```js
cache.get('invalid'); // undefined
```

To differentiate from a key-value that hasn't be set, you can use `null`:

```js
cache.set('invalid', null);
```

### Delete

Delete key-value from store:

```js
cache.delete('key');
```

### Clear

Clear store:

```js
cache.clear();
```

This means the store becomes an empty object:

```js
cache.get(); // {}
```

## Testing

Run tests with coverage:

```sh
$ npm test
```

Run tests in watch mode:

```sh
$ npm run test:watch
```

Lint files:

```sh
$ npm run lint
```

Fix lint errors:

```sh
$ npm run lint:fix
```

## Release

Only collaborators with credentials can release and publish:

```sh
$ npm run release
$ git push --follow-tags && npm publish
```

## License

[MIT](https://github.com/remarkablemark/imc/blob/master/LICENSE)

---
_Source: https://npm.io/package/imc · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
