# afn-redis-cache

> A shared network cache for https://github.com/MatAtBread/afn to speed up clustered API servers

Latest version **3.0.1** (published 2020-11-05) · MIT license · 0 weekly downloads

## Install

```sh
npm install afn-redis-cache
pnpm add afn-redis-cache
yarn add afn-redis-cache
bun add afn-redis-cache
```

## 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 | 3.0.1 |
| Published | 2020-11-05 |
| First published | 2016-10-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=10.0.0 |
| Dependencies | 1 |
| Unpacked size | 11 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 1 |
| Author | https://github.com/MatAtBread |
| Maintainers | matatbread |
| Keywords | async, map, cache, redis |

## Links

- npm: https://www.npmjs.com/package/afn-redis-cache
- Repository: https://github.com/MatAtBread/afn-redis-cache
- Homepage: https://github.com/MatAtBread/afn-redis-cache#readme
- Issues: https://github.com/MatAtBread/afn-redis-cache/issues
- npm.io page: https://npm.io/package/afn-redis-cache

## Dependencies (1)

- [redis](https://npm.io/package/redis.md) ^2.6.5

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

- 3.0.1 (latest) — 2020-11-05
- 3.0.0 — 2020-10-28
- 2.1.1 — 2020-02-14
- 2.1.0 — 2019-09-20
- 2.0.8 — 2019-09-19
- 2.0.7 — 2019-08-06
- 2.0.3 — 2019-06-27
- 2.0.1 — 2019-05-18
- 1.2.1 — 2018-07-02
- 1.2.0 — 2017-10-20
- 1.1.2 — 2017-08-11
- 1.1.1 — 2017-02-16
- 1.1.0 — 2017-02-08
- 1.0.3 — 2017-02-02
- 1.0.2 — 2016-11-08
- … 2 more at https://npm.io/package/afn-redis-cache/versions

## README

# afn-redis-cache

A shared network cache for https://github.com/MatAtBread/afn to speed up clustered API servers

Installation
------------

	npm install --save afn-redis-cache
	
Usage
-----

Require the module

	var configureCache = require('afn-redis-cache') ;
	
Configure the cache and get a function to create caches with that configuration
You can create multiple 'cacheCreators' with different configurations by calling configureCache() multiple times

	var cacheCreator = configureCache({
		defaultTTL:60	// 1 minute by default
		redis:			// Any valid redis createClient parameter (see https://github.com/NodeRedis/node_redis/blob/master/README.md#options-object-properties)
			"redis":"redis://127.0.0.1:6379/13"		//eg. a 'redis_url'
	}) ;
	
Now create a cache	
	
	// "id" is an optional alphanumeric string prepended to cache entries,
	// so you can (on the same redis DB) create multiple caches that won't collide 
	var cache = cacheCreator.createCache(id) ;
	
Use the cache	
	
	// Async cache API - a subset of a JavaScript Map API
	await cache.get(key);
	await cache.set(key,data,ttl);
	await cache.delete:(key);
	await cache.keys();

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