# ads-cache

> using ads instead of redis in private cloud

Latest version **1.0.1** (published 2018-08-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install ads-cache
pnpm add ads-cache
yarn add ads-cache
bun add ads-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.1 |
| Published | 2018-08-28 |
| First published | 2018-08-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=8.9.0 |
| Dependencies | 1 |
| Unpacked size | 10.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | taozhi |
| Maintainers | taozhi.tz |
| Keywords | ganjiang, ads, redis |

## Links

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

## Dependencies (1)

- [mysql](https://npm.io/package/mysql.md) ^2.16.0

## 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.1 (latest) — 2018-08-28
- 1.0.0 — 2018-08-28

## README

# ADS CACHE

> Redis is missing in special private cloud environments, with ads as an alternative. This package provides common commands in redis such as set, get, del, etc., less codes would be modified to complete the migration from redis to ads.

## Install Package

```sh
$ npm install ads-cache --save
```

## Usage

```js
  const AdsCache = require('ads-cache')
```

### INIT CLIENT

- the redis config VS ads config

| property | redis | ads |
|:-----:|:-----:|:------:|
|host | host| host|
|port| port | port |
|password | auth | password |
|database | x | database |
|tableGroup | x | tableGroup |
|table | db | table |

```js
  const host = 'ads-host' // required
  const port = ads-port // required
  const user = 'user' // required
  const password = 'password' // required
  const database = 'databse' // required
  const tableGroup = 'table group' // table group is required for each table in ads 
  const table = 'zero' // optional the table name default is zero
  const prefix = 'gj:' // optional you could set each key prefix for namespace
  const client = new AdsCache({
    host,
    port,
    user,
    password,
    database,
    tableGroup,
    prefix,
    table
  })
```

### SET 

```js
  await client.set('key', 'value') // 'OK'
```

### GET

```js
  await client.get('key') // 'value'
```

### DEL

```js
  await client.del('key') // 'OK'
  await client.del('key1', 'key2', 'key3')
```

### EXPIRE

```js
  await client.expire('key', 30) // 30s
```

### SELECT

```js
  await client.select('one') // change to table one, create table one if not exists automatically
```

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