# mon-cache

> Mon-cache is mongoose cache for redis, memcached, or lru-cache

Latest version **0.0.1** (published 2015-04-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install mon-cache
pnpm add mon-cache
yarn add mon-cache
bun add mon-cache
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.1 |
| Published | 2015-04-26 |
| First published | 2015-04-26 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Justin Park |
| Maintainers | asterisk |
| Keywords | mongoose, cache, lru-cache, memcached, redis |

## Links

- npm: https://www.npmjs.com/package/mon-cache
- Repository: https://github.com/devAsterisk/mon-cache
- Homepage: https://github.com/devAsterisk/mon-cache.git
- Issues: https://github.com/devAsterisk/mon-cache/issues
- npm.io page: https://npm.io/package/mon-cache

## Dependencies (2)

- [async](https://npm.io/package/async.md) ^0.9.0
- [cache-client](https://npm.io/package/cache-client.md) *

## 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

- 0.0.1 (latest) — 2015-04-26

## README

# mon-cache
mon-cache is mongoose cache to redis, memcached, or lru-cache.  This utilizes the npm modules cache-client.
<br />

## Initialization

### lru-cache
```javascript
options = {
  store: "memory"
};

require('mon-cache')(mongoose, options);
```

### redis
```javascript
options = {
  store: "redis",
  port:6379,
  host:"127.0.0.1",
  auth:"password",  // optional
  select_db: 0      // optional, default is 0
};

require('mon-cache')(mongoose, options);
```

### memcached
```javascript
options = {
  store: "memcached",
  host:"localhost:11211"
};

require('mon-cache')(mongoose, options);
```

### additional options
```javascript
options = {
  cache: false, // global option to disable caching
  ttl: 60,      // global option to set ttl(sec), default is 60 sec
  debug: true	// print logs for debug
};
```
## Usage

Enable cache with ttl in options.
If you don't set ttl, default ttl is 60 sec.

```javascript
MyModel.find({ ... })
  .cache()
  .exec(function(err, result) { ... });
```
or

```javascript
query.cache(true)      // can explicit enable (or disable) caching
query.cache(10)        // enable caching with 10 sec ttl
query.cache(true, 10)  // enable caching with 10 sec ttl
```

##Contact

* email: asterisk@makeus.com

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