WECHATY-PUPPET-CACHE
Aim
- support multiple types of cache store,
mongo
andflash-store
- defined the object payload structure for wechaty-puppet-xxx
Install
Node
version first
1. Check your 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:
-
wechaty-cache-message-raw-payload
-
wechaty-cache-room-raw-payload
-
wechaty-cache-contact-raw-payload
-
wechaty-cache-room-invitation-raw-payload
-
wechaty-cache-room-member-raw-payload
-
wechaty-cache-friendship
Please make sure there's no conflict with your table name.