Use auraStorage:init to initialize storage in your app’s template for caching server-side action response values.
This example uses a template to initialize storage for server-side action response values. The template contains an auraStorage:init tag that specifies storage initialization properties.
<aura:component isTemplate="true" extends="aura:template"> <aura:set attribute="auraPreInitBlock"> <!-- Note that the maxSize attribute in auraStorage:init is in KB --> <auraStorage:init name="actions" persistent="false" secure="false" maxSize="1024" /> </aura:set> </aura:component>
When you initialize storage, you can set certain options, such as the name, maximum cache size, and the default expiration time.
Storage for server-side actions caches action response values. The storage name must be actions.
Attribute Name | Attribute Type | Description | Required? |
---|---|---|---|
body | Component[] | The body of the component. In markup, this is everything in the body of the tag. | |
clearStorageOnInit | Boolean | Set to true to delete all previous data on initialization (relevant for persistent storage only). This value defaults to true. | |
debugLoggingEnabled | Boolean | Set to true to enable debug logging with $A.log(). This value defaults to false. | |
defaultAutoRefreshInterval | Integer | The default duration (seconds) before an auto refresh request will be initiated. Actions may override this on a per-entry basis with Action.setStorable(). This value defaults to 30. | |
defaultExpiration | Integer | The default duration (seconds) that an object will be retained in storage. Actions may override this on a per-entry basis with Action.setStorable(). This value defaults to 10. | |
maxSize | Integer | Maximum size (KB) of the storage instance. Existing items will be evicted to make room for new items; algorithm is adapter-specific. This value defaults to 1000. | |
name | String | The programmatic name for the storage instance. | Yes |
persistent | Boolean | Set to true if this storage desires persistence. This value defaults to false. | |
secure | Boolean | Set to true if this storage requires secure storage support. This value defaults to false. | |
version | String | Version to associate with all stored items. |