1.2.0 • Published 6 years ago
ssb-cached-about v1.2.0
ssb-cached-about
A client-side cache for ssb-about
This plugin is meant for the frontend (but also can run in the backend!) of your SSB app, and uses LRU cache to avoid looking up common ssb-about queries.
Usage
Prerequisities:
ssb-aboutis installed in your app backend (in nodejs-mobile)- React Native if running in the client
react-native-ssb-clientversion 5 or higher
npm install --save ssb-cached-aboutInstall it in your react-native-ssb-client:
import ssbClient from 'react-native-ssb-client'
import cachedAbout from 'ssb-cached-about'
// ...
ssbClient(keys, manifest)
.use(cachedAbout())
.call(null, (err, ssb) => {
// ...
// You can now call this:
ssb.cachedAbout.socialValue({key: 'image', dest: keys.id}, (e, val) => {
// ...
})
})API
socialValue(opts, callback): same as ssb-about'ssocialValue(), but has a cache built ininvalidate(opts): invalidate the cache for the IDopts.dest, and (OPTIONAL) fieldopts.key, where theoptsobject is similar to that one insocialValue(opts, cb)
License
MIT