# wechaty-puppet-cache

> cache component for wechaty,support mongo and flash-store

Latest version **0.1.10** (published 2020-06-22) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install wechaty-puppet-cache
pnpm add wechaty-puppet-cache
yarn add wechaty-puppet-cache
bun add wechaty-puppet-cache
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.10 |
| Published | 2020-06-22 |
| First published | 2020-06-02 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >= 10 |
| Dependencies | 5 |
| Unpacked size | 115.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | iguxiaobei |
| Maintainers | iguxiaobei |
| Keywords | wechaty, cache, mongo, flash-store |

## Links

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

## Dependencies (5)

- [brolog](https://npm.io/package/brolog.md) ^1.8.3
- [moment](https://npm.io/package/moment.md) ^2.26.0
- [mongodb](https://npm.io/package/mongodb.md) ^3.5.8
- [flash-store](https://npm.io/package/flash-store.md) ^0.14.5
- [wechaty-puppet](https://npm.io/package/wechaty-puppet.md) ^0.24.0

## Alternatives

- [angular-pipes](https://npm.io/package/angular-pipes.md) — 5.6K weekly downloads
- [@ng-web-apis/midi](https://npm.io/package/@ng-web-apis/midi.md) — 2.6K weekly downloads
- [happn-3](https://npm.io/package/happn-3.md) — 1.6K weekly downloads
- [@opensip-cli/lang-go](https://npm.io/package/@opensip-cli/lang-go.md) — 1.2K weekly downloads
- [mongoose-typescript](https://npm.io/package/mongoose-typescript.md) — 85 weekly downloads

## Recent versions

- 0.1.10 (latest) — 2020-06-22
- 0.1.9 — 2020-06-14
- 0.1.7 — 2020-06-07
- 0.1.6 — 2020-06-05
- 0.1.4 — 2020-06-05
- 0.1.3 — 2020-06-05
- 0.1.2 — 2020-06-02
- 0.1.1 — 2020-06-02
- 0.1.0 — 2020-06-02
- 0.1.5 — 2020-06-02

## README

# WECHATY-PUPPET-CACHE

[![Powered by Wechaty](https://img.shields.io/badge/Powered%20By-Wechaty-blue.svg)](https://github.com/chatie/wechaty)
[![NPM Version](https://badge.fury.io/js/wechaty-puppet-cache.svg)](https://www.npmjs.com/package/wechaty-puppet-cache)
[![TypeScript](https://img.shields.io/badge/%3C%2F%3E-TypeScript-blue.svg)](https://www.typescriptlang.org/)
[![Linux/Mac Build Status](https://travis-ci.com/wechaty/wechaty-puppet-cache.svg?branch=master)](https://travis-ci.com/wechaty/wechaty-puppet-cache)

## Aim

1. support multiple types of cache store, `mongo` and `flash-store`
2. defined the object payload structure for wechaty-puppet-xxx

## Install

### 1. Check your `Node` version first

```shell
node --version // v10.16.0
```

> for windows system

To make sure you could install `wechaty-puppet-cache` successfully, you have to start PowerShell as Administrator and run these commands:

```shell
npm install -g windows-build-tools

npm install -g node-gyp
```

### 2. Cache store types

- flash-store[default]
- mongo

### 3. How to use wechaty-puppet-cache

#### For default
```ts
import PupetCache from 'wecahty-puppet-cache'

const puppetCache = new PuppetCache({
  name: 'your name',
})
const messageCache = puppetCache.genMessageClient()
const contactCache = puppetCache.genContactClient()
const roomMemberCache = puppetCache.genRoomMemberClient()
const roomCache = puppetCache.genRoomClient()
const friendshipCache = puppetCache.genFriendshipClient()
const roomInvitationCache = puppetCache.genRoomInvitationClient()
const otherCache = puppetCache.genClient('your cache name')
```

#### For mongo

```ts
import PupetCache, { PuppetCacheStoreOptions } from 'wecahty-puppet-cache'

const storeOptions: PuppetCacheStoreOptions = {
  type: 'mongo',
  url: 'mongodb://127.0.0.1:27017/testdb',
}
const puppetCache = new PuppetCache({
  name: 'your name',
  storeOptions,
})
```


### 4. Caution

> When you use mongo as cache store, the table name list:

1. wechaty-cache-message-raw-payload

2. wechaty-cache-room-raw-payload

3. wechaty-cache-contact-raw-payload

4. wechaty-cache-room-invitation-raw-payload

5. wechaty-cache-room-member-raw-payload

6. wechaty-cache-friendship

> Please make sure there's no conflict with your table name.

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