1.2.0 • Published 4 years ago

ssb-cached-about v1.2.0

Weekly downloads
1
License
MIT
Repository
gitlab
Last release
4 years ago

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-about is installed in your app backend (in nodejs-mobile)
  • React Native if running in the client
  • react-native-ssb-client version 5 or higher
npm install --save ssb-cached-about

Install 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's socialValue(), but has a cache built in
  • invalidate(opts): invalidate the cache for the ID opts.dest, and (OPTIONAL) field opts.key, where the opts object is similar to that one in socialValue(opts, cb)

License

MIT

1.2.0

4 years ago

1.1.0

4 years ago

1.0.0

5 years ago