@juzi/wechaty-puppet-cache
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

WECHATY-PUPPET-CACHE

Powered by Wechaty NPM Version TypeScript Linux/Mac Build Status

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

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:

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

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

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.

Package Sidebar

Install

npm i @juzi/wechaty-puppet-cache

Weekly Downloads

1

Version

1.0.0

License

Apache-2.0

Unpacked Size

135 kB

Total Files

99

Last publish

Collaborators

  • binsee
  • juzi-admin