# cacheous

> 1. _You like to ensure your data is clear and fully valid._ Schemas provide a quick way to provide validation for your data.

Latest version **1.0.1** (published 2019-06-11) · MIT license · 0 weekly downloads

## Install

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

## 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.1 |
| Published | 2019-06-11 |
| First published | 2019-04-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 5 |
| Unpacked size | 5.9 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 2 |
| Maintainers | cjrutherfordnyc |

## Links

- npm: https://www.npmjs.com/package/cacheous
- Repository: https://github.com/cjrutherford/cacheous
- Homepage: https://github.com/cjrutherford/cacheous#readme
- Issues: https://github.com/cjrutherford/cacheous/issues
- npm.io page: https://npm.io/package/cacheous

## Dependencies (5)

- [keyv](https://npm.io/package/keyv.md) ^3.1.0
- [schm](https://npm.io/package/schm.md) ^0.4.1
- [uuid](https://npm.io/package/uuid.md) ^3.3.2
- [@keyv/mongo](https://npm.io/package/@keyv/mongo.md) ^1.1.0
- [@keyv/sqlite](https://npm.io/package/@keyv/sqlite.md) ^2.0.0

## Recent versions

- 1.0.1 (latest) — 2019-06-11
- 1.0.0 — 2019-04-13

## README

# Cacheous

## A small wrapper that adds extra functionality to Keyv.

## Assumptions:

1. _You like to ensure your data is clear and fully valid._
   Schemas provide a quick way to provide validation for your data.

2. _You like your data fast, but also safe._
   Keeping data inside an in memory cache quickly allows applications to respond to requests, and using a persistent data store keeps it safe across multiple instances.

## Creating the Schema

To Create a Schema for Cacheous, use the [`schm`](https://github.com/diegohaz/schm) package from npm to define your schema as you would in Mongoose. Then the schema provided in the constructor.

Please see the documentation for [`diegohaz/schm`](https://github.com/diegohaz/schm) for how to define or extend your shcema.

## Constructor Sample

```
cosnt Cacheous = require('cacheous');
cosnt ObjectSchema = require('./schema');

const ObjectCache = new Cacheous({
    name: 'Objects',
    storeURI: 'connectionstring for supported data stores',
    schema: ObjectSchema
});
```

## Api Reference

### `getIdList(): Promise<Array<String>>`

Returns the list of ID's in the model set.

### `getById(id: String): Promise<Model>`

Returns a Model Object that is at the specified ID.

### `where(filter: Function): Promise<Array<Model>>`

Accepts a lambda to filter the objects in the store, and returns an array of objects for which the lambda is true.

### `insert(m: Model): Promise<Model>`

Accepts an object of the model, validates it against the schema, and inserts into the cache.

### `destroy(id: String): Promise<Boolean>`

Accepts an ID, and removes it from the cache.

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