# task-log-cache

> redis-based task-log-cache

Latest version **1.0.3** (published 2019-08-21) · MIT license · 0 weekly downloads

## Install

```sh
npm install task-log-cache
pnpm add task-log-cache
yarn add task-log-cache
bun add task-log-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 | 1.0.3 |
| Published | 2019-08-21 |
| First published | 2019-08-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 20 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | drpaulbrewer@eaftc.com |
| Maintainers | drpaulbrewer |
| Keywords | redis, tasks, task log |

## Links

- npm: https://www.npmjs.com/package/task-log-cache
- Repository: https://github.com/drpaulbrewer/task-log-cache
- Homepage: https://github.com/drpaulbrewer/task-log-cache#readme
- Issues: https://github.com/drpaulbrewer/task-log-cache/issues
- npm.io page: https://npm.io/package/task-log-cache

## Dependencies (1)

- [@hapi/joi](https://npm.io/package/@hapi/joi.md) ^15.0.3

## 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.3 (latest) — 2019-08-21
- 1.0.2 — 2019-08-21
- 1.0.1 — 2019-08-21
- 1.0.0 — 2019-08-21

## README

# task-log-cache

[![Build Status](https://travis-ci.org/DrPaulBrewer/task-log-cache.svg?branch=master)](https://travis-ci.org/DrPaulBrewer/task-log-cache)
[![Coverage Status](https://coveralls.io/repos/github/DrPaulBrewer/task-log-cache/badge.svg?branch=master)](https://coveralls.io/github/DrPaulBrewer/task-log-cache?branch=master) [![Greenkeeper badge](https://badges.greenkeeper.io/DrPaulBrewer/task-log-cache.svg)](https://greenkeeper.io/)

Redis-based task status log/cache

## Installation

```
npm i ioredis -S
npm i task-log-cache -S
```

## Dependencies

Developers using this library must pass a configured `npm:ioredis` client on initialization.  

`npm:@hapi/joi` is used for initial validation.

## Initialization

Below is a sample configuration to:

```
const IoRedis = require('ioredis');
const taskStatusCache = require('task-status-cache');
const redisServerLocal = {
  host: "localhost",
  port: 6379,
  retryStrategy(times) {
    const delay = Math.min(times * 100, 2000);
    return delay;
  }
};
const ioredis = new IoRedis(redisServerLocal);
const tasklogger = taskStatusCache({
    ioredis,
    prefix: 'task:',
    index: 'tasks',
    ttl: 3600*24*3, // keep 3 days
    ttlRenewOnWrite: true,
    ttlRenewOnRead: false
});
```

## Usage

```
await tasklogger.push(key, item);
await tasklogger.summary()
await tasklogger.get(key, ifrom, ito);
await tasklogger.delete(key)
await tasklogger.reap()
```

## Tests

To test:

First, spin up a redis database on localhost using docker

```
 docker run -v /tmp/data:/data \
    --name "red" \
    -d \
    -p 127.0.0.1:6379:6379 \
    redis redis-server --appendonly yes
```

Warning:  Testing will FLUSHALL and DELETES THE ENTIRE DATABSE on localhost.  

```
npm test
```

After running npm test, you may want to delete the redis docker container.

```
docker kill red
docker rm red
```

### Copyright

Copyright 2019 Paul Brewer, Economic and Financial Technology Consulting LLC

### License

The MIT license

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

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