radio4000 / components

web-components to build the r4 interfaces, uses the sdk
https://components.radio4000.com/
1 stars 0 forks source link

Client-side cache #89

Open oskarrough opened 1 year ago

oskarrough commented 1 year ago

Not to be merged. Playing around with it.

netlify[bot] commented 1 year ago

Deploy Preview for radio4000-components ready!

Name Link
Latest commit f59664dd103c758424a0aa605c03c2bdad69c849
Latest deploy log https://app.netlify.com/sites/radio4000-components/deploys/6491a518ccba990008d89af1
Deploy Preview https://deploy-preview-89--radio4000-components.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

oskarrough commented 1 year ago

The new Cache saves the results of queries in a map. It only sends a new request when 1) it's an unknown query 2) cache expired (by default 1 min). Access the cache on this.store.cache.

before

const {data, error} = await sdk.channels.readChannel(slug)

after

const {data, error} = await this.store.cache.get(`channel/${slug}`, () => sdk.channels.readChannel(slug))