# cachedo

Latest version **1.0.0** (published 2018-06-05) · ISC license · 0 weekly downloads

## Install

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

## 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 | 2018-06-05 |
| First published | 2018-06-05 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 30.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Justin Mathews |
| Maintainers | jmathews-shiver |

## Links

- npm: https://www.npmjs.com/package/cachedo
- npm.io page: https://npm.io/package/cachedo

## Dependencies (2)

- [jsondo](https://npm.io/package/jsondo.md) ^2.0.3
- [objcheck](https://npm.io/package/objcheck.md) ^1.0.6

## Recent versions

- 1.0.0 (latest) — 2018-06-05

## README

<!-- Generated by documentation.js. Update this documentation by updating the source code. -->

### Table of Contents

-   [CacheDo][1]
    -   [setCache][2]
    -   [setOptions][3]
    -   [hashKey][4]
    -   [setKet][5]
    -   [put][6]
    -   [get][7]

## CacheDo

Cache abstraction that supports merging cached values with new and key hashing

**Parameters**

-   `cacheClass` **Class** Caching class with get, put, del methods
-   `options` **[JSON][8]** Class operation definition
    -   `options.merge` **[Boolean][9]** (false) Enable/Disable merging new value with present value if one exists
    -   `options.keys` **[JSON][8]** Defines options specific to key management
        -   `options.keys.hashKey` **[Boolean][9]** (false) Enable/Disable key hashing
        -   `options.keys.algorithm` **[String][10]** (sha256) Defines algorith used during key hash
        -   `options.keys.digest` **[String][10]** (hex) Defines digest used during key hash
        -   `options.keys.keyGen` **[Function][11]** ((input)=>{return input}) Custom function to produce key
    -   `options.ttl` **[Number][12]** (600) Define expire time of the cached value
    -   `options.timeoutCB` **([Undefined][13] \| [Function][11])** (Undefined) Custom callback function to be executed when cache value expires

**Meta**

-   **version**: 1.0.0

### setCache

Validates caching function by ensuring that it contains methods
get, put, del

**Parameters**

-   `cacheClass` **[Function][11]** Caching function

### setOptions

Merges and returns a validated option set

**Parameters**

-   `options` **[JSON][8]** Class operation definition
    -   `options.merge` **[Boolean][9]** (false) Enable/Disable merging new value with present value if one exists
    -   `options.keys` **[JSON][8]** Defines options specific to key management
        -   `options.keys.hashKey` **[Boolean][9]** (false) Enable/Disable key hashing
        -   `options.keys.algorithm` **[String][10]** (sha256) Defines algorith used during key hash
        -   `options.keys.digest` **[String][10]** (hex) Defines digest used during key hash
        -   `options.keys.keyGen` **[Function][11]** ((input)=>{return input}) Custom function to produce key
    -   `options.ttl` **[Number][12]** (600) Define expire time of the cached value
    -   `options.timeoutCB` **([Undefined][13] \| [Function][11])** (Undefined) Custom callback function to be executed when cache value expires

### hashKey

Produces hash of parameter.

**Parameters**

-   `input` **([Number][12] \| [String][10] \| [JSON][8])** Value to be hashed

### setKet

Generates key based on configuration settings

**Parameters**

-   `input` **([Number][12] \| [String][10] \| [JSON][8])** Value to be hashed

### put

Pushes key/value pair to cache

**Parameters**

-   `key` **[String][10]** 
-   `value` **([Number][12] \| [String][10] \| [JSON][8])** Value to be cached
-   `options` **[JSON][8]** Optional options passed that will override options used during class instantiation
    -   `options.merge` **[String][10]** Enable/Disable merging new value with present value if one exists
    -   `options.ttl` **[String][10]** Define expire time of the cached value
    -   `options.timeoutCB` **[String][10]** Custom callback function to be executed when cache value expires

### get

Calls cache to return value assigned to key

**Parameters**

-   `key` **[String][10]** 

[1]: #cachedo

[2]: #setcache

[3]: #setoptions

[4]: #hashkey

[5]: #setket

[6]: #put

[7]: #get

[8]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/JSON

[9]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean

[10]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String

[11]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function

[12]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number

[13]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined

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