npm.io
0.1.10 • Published 6 years ago

wechaty-puppet-cache

Licence
Apache-2.0
Version
0.1.10
Deps
5
Size
115 kB
Vulns
0
Weekly
0

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.

Keywords