ssb-cached-about
TypeScript icon, indicating that this package has built-in type declarations

1.2.0 • Public • Published

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

Readme

Keywords

none

Package Sidebar

Install

npm i ssb-cached-about

Weekly Downloads

1

Version

1.2.0

License

MIT

Unpacked Size

5.62 kB

Total Files

6

Last publish

Collaborators

  • staltz