# cahey

> In-memory db for caching

Latest version **1.1.6** (published 2020-09-26) · ISC license · 0 weekly downloads

## Install

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

## 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.1.6 |
| Published | 2020-09-26 |
| First published | 2020-09-25 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 5.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | d4rckh |
| Maintainers | d4rckh |

## Links

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

## Recent versions

- 1.1.6 (latest) — 2020-09-26
- 1.1.5 — 2020-09-26
- 1.0.5 — 2020-09-26
- 1.0.4 — 2020-09-26
- 1.0.3 — 2020-09-25
- 1.0.2 — 2020-09-25
- 1.0.1 — 2020-09-25

## README

# Cahey
cache key-value "database" 100% free and lightweight :)

## Install
```
npm i cahey
```

## Tutorial
```js
// init the library
const Cahey = require("cahey")
```
```js
// create a new server
const Server = new Cahey.Server()
```
```js
// create a new session which will most likely be set per IP
// first param is the name of it
// second param is the timeout of cache for every single key-value
const Session = Server.createSession("my-session", 1000/*ms*/)
```
```js
// import express
const express = require("express")
```
```js
// init the api-response variable, second param can be it's init value or by default it's undefined
Session.store("api-response")
```
```js
// create a new express app
const app = express()
```
```js
// create a new route
app.get("/", (req, res) => {
    // this will grab or renew the api-response based on the timeout you set
    res.json(Session.grabOrRenew("api-response", () => {
        return {
            // here you can do some database querying or whatever, ill put some dummy data
            numbers: [
                "1", "2", "7", "10"
            ]
        }
    }))
})
```
```js
// listen to requests
app.listen(1010)
```

Now when you go to the `/` of your web server, the renew function will be called every single second! You can make the timeout higher for less calls of your renew function! Have fun

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