chore: cleanup

This commit is contained in:
Joren Broekema 2021-02-18 10:59:55 +01:00 committed by Thomas Allmer
parent 15e2d13589
commit 28dbf3d232
2 changed files with 7 additions and 8 deletions

View file

@ -225,9 +225,9 @@ Alternatively, most often for subclassers, you can extend or import `AjaxClient`
```js ```js
import { AjaxClient } from '@lion/ajax'; import { AjaxClient } from '@lion/ajax';
export const ajax = new AjaxClient({ export const ajax = new AjaxClient({
cacheOptions: { cacheOptions: {
useCache: true, useCache: true,
timeToLive: 1000 * 60 * 5, // 5 minutes timeToLive: 1000 * 60 * 5, // 5 minutes
getCacheIdentifier: () => getActiveProfile().profileId, getCacheIdentifier: () => getActiveProfile().profileId,
}, },
@ -319,8 +319,8 @@ After TTL expires, the next request will set the cache again, and for the next 3
export const cacheTimeToLive = () => { export const cacheTimeToLive = () => {
const actionLogger = renderLitAsNode(html`<sb-action-logger></sb-action-logger>`); const actionLogger = renderLitAsNode(html`<sb-action-logger></sb-action-logger>`);
const fetchHandler = () => { const fetchHandler = () => {
ajax.requestJson(`./packages/ajax/docs/pabu.json`, { ajax.requestJson(`./packages/ajax/docs/pabu.json`, {
cacheOptions: { cacheOptions: {
timeToLive: 1000 * 3, // 3 seconds timeToLive: 1000 * 3, // 3 seconds
} }
}) })
@ -441,7 +441,7 @@ export const invalidateRules = () => {
actionCacheOptions.invalidateUrlsRegex = /\/packages\/ajax\/docs\/naga.json/; actionCacheOptions.invalidateUrlsRegex = /\/packages\/ajax\/docs\/naga.json/;
} }
ajax.requestJson(`./packages/ajax/docs/${name}.json`, { ajax.requestJson(`./packages/ajax/docs/${name}.json`, {
method, method,
cacheOptions: actionCacheOptions, cacheOptions: actionCacheOptions,
}) })
@ -463,4 +463,4 @@ export const invalidateRules = () => {
${actionLogger} ${actionLogger}
`; `;
} }
``` ```

View file

@ -253,7 +253,6 @@ export const cacheRequestInterceptorFactory = (getCacheIdentifier, globalCacheOp
if (cacheOptions.invalidateUrls) { if (cacheOptions.invalidateUrls) {
cacheOptions.invalidateUrls.forEach( cacheOptions.invalidateUrls.forEach(
/** @type {string} */ invalidateUrl => { /** @type {string} */ invalidateUrl => {
console.log('invalidaaaating', currentCache._cacheObject);
currentCache.delete(invalidateUrl); currentCache.delete(invalidateUrl);
}, },
); );