Newer Version Available
Initializing Storage Service
Initialize in Markup
You can initialize storage for your component using markup by using a template or by adding the markup in the component body.
This example shows how to use a template to initialize storage. The component references the template in the template attribute.
1<aura:component render="client" template="auraStorageTest:namedStorageTemplate">
2</aura:component>The template contains auraStorage:init tags that specify storage initialization properties. This example initializes three different storages: the framework-provided actions storage, and two custom storages named savings and checking.
1<aura:component isTemplate="true" extends="aura:template">
2 <aura:set attribute="auraPreInitBlock">
3 <!-- Note that the maxSize attribute in <auraStorage:init> is in KB -->
4 <auraStorage:init name="actions" persistent="false" secure="false"
5 maxSize="9999" version="1.0"/>
6 <auraStorage:init name="savings" persistent="false" secure="true"
7 maxSize="6666"/>
8 <auraStorage:init name="checking" maxSize="7777"/>
9 </aura:set>
10</aura:component>Alternatively, you can add auraStorage:init tags directly in the body of your component markup. This example shows component markup that initializes a storage named savings.
1<aura:component render="client" extensible="true"
2 controller="java://org.auraframework.impl.java.controller.AuraStorageTestController"
3 implements="auraStorage:refreshObserver">
4
5 <auraStorage:init debugLoggingEnabled="true"
6 name="savings"
7 secure="true"
8 persistent="false"
9 clearStorageOnInit="true"
10 defaultExpiration="50"
11 defaultAutoRefreshInterval="60"
12 version="1.0" />
13</aura:component>