PageSourceSearch

https://managedcomponents.dev/assets/js/e3b14c36.1f37cc50.js

js managedcomponents.dev collected 2026-10-02 03:02:26 UTC 4,663 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunkmanagedcomponents_dev=self.webpackChunkmanagedcomponents_dev||[]).push([[6677],{3905:function(e,t,n){n.d(t,{Zo:function(){return p},kt:function(){return d}});var r=n(7294);function a(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function c(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function i(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?c(Object(n),!0).forEach((function(t){a(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):c(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function o(e,t){if(null==e)return{};var n,r,a=function(e,t){if(null==e)return{};var n,r,a={},c=Object.keys(e);for(r=0;r<c.length;r++)n=c[r],t.indexOf(n)>=0||(a[n]=e[n]);return a}(e,t);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(e);for(r=0;r<c.length;r++)n=c[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}var s=r.createContext({}),u=function(e){var t=r.useContext(s),n=t;return e&&(n="function"==typeof e?e(t):i(i({},t),e)),n},p=function(e){var t=u(e.components);return r.createElement(s.Provider,{value:t},e.children)},l={inlineCode:"code",wrapper:function(e){var t=e.children;return r.createElement(r.Fragment,{},t)}},h=r.forwardRef((function(e,t){var n=e.components,a=e.mdxType,c=e.originalType,s=e.parentName,p=o(e,["components","mdxType","originalType","parentName"]),h=u(n),d=a,f=h["".concat(s,".").concat(d)]||h[d]||l[d]||c;return n?r.createElement(f,i(i({ref:t},p),{},{components:n})):r.createElement(f,i({ref:t},p))}));function d(e,t){var n=arguments,a=t&&t.mdxType;if("string"==typeof e||a){var c=n.length,i=new Array(c);i[0]=h;var o={};for(var s in t)hasOwnProperty.call(t,s)&&(o[s]=t[s]);o.originalType=e,o.mdxType="string"==typeof e?e:a,i[1]=o;for(var u=2;u<c;u++)i[u]=n[u];return r.createElement.apply(null,i)}return r.createElement.apply(null,n)}h.displayName="MDXCreateElement"},3589:function(e,t,n){n.r(t),n.d(t,{assets:function(){return p},contentTitle:function(){return s},default:function(){return d},frontMatter:function(){return o},metadata:function(){return u},toc:function(){return l}});var r=n(7462),a=n(3366),c=(n(7294),n(3905)),i=["components"],o={},s="useCache",u={unversionedId:"cache/useCache",id:"cache/useCache",title:"useCache",description:"The useCache method is used to provide tools with an abstract layer of caching that easy to use. The method takes 3 arguments - name, function and expiry. When used, useCache will use the data from the cache if it exists, and if the expiry time did not pass. If it cannot use the cache, useCache will run the function and cache it for next time.",source:"@site/specs/cache/useCache.md",sourceDirName:"cache",slug:"/cache/useCache",permalink:"/specs/cache/useCache",draft:!1,editUrl:"https://github.com/managed-components/docs/edit/main/specs/cache/useCache.md",tags:[],version:"current",frontMatter:{},sidebar:"tutorialSidebar",previous:{title:"invalidateCache",permalink:"/specs/cache/invalidateCache"}},p={},l=[],h={toc:l};function d(e){var t=e.components,n=(0,a.Z)(e,i);return(0,c.kt)("wrapper",(0,r.Z)({},h,n,{components:t,mdxType:"MDXLayout"}),(0,c.kt)("h1",{id:"usecache"},(0,c.kt)("inlineCode",{parentName:"h1"},"useCache")),(0,c.kt)("p",null,"The ",(0,c.kt)("inlineCode",{parentName:"p"},"useCache")," method is used to provide tools with an abstract layer of caching that easy to use. The method takes 3 arguments - ",(0,c.kt)("inlineCode",{parentName:"p"},"name"),", ",(0,c.kt)("inlineCode",{parentName:"p"},"function")," and ",(0,c.kt)("inlineCode",{parentName:"p"},"expiry"),". When used, ",(0,c.kt)("inlineCode",{parentName:"p"},"useCache")," will use the data from the cache if it exists, and if the expiry time did not pass. If it cannot use the cache, ",(0,c.kt)("inlineCode",{parentName:"p"},"useCache")," will run the function and cache it for next time."),(0,c.kt)("pre",null,(0,c.kt)("code",{parentName:"pre",className:"language-js"},"await manager.useCache(\n  `widget-${tweet.id}`,\n  pug.compile('templates/floating-widget.pug', { tweet }),\n  60\n)\n")),(0,c.kt)("p",null,"In the above example the template will only be rerendered using Pug if the cache doesn't already have the rendered template saved, or if it has been more than 60 seconds since the time it was cached."))}d.isMDXComponent=!0}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.