function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Gaurav  PuranikGaurav Puranik 

AuraStorage:init is not holding data for more then 6,7 seconds

Hi all,

My component code:-
<aura:set attribute="auraPreInitBlock">
    <auraStorage:init debugLoggingEnabled="true"
                         name="actions"
                         persistent="false" secure="true"
                         clearStorageOnInit="true"
                         defaultExpiration="3600"
                         maxSize="10485760" version="1.0"/>
    </aura:set> 

On the client side controller :-
doInit:function(cmp, evt, helper){
// Get server-side action
var action = cmp.get("c.fetchDataRecord");
action.setCallback(cmp, function(response){
var returnValue = response.getReturnValue();
});
// Set server-side action as storable
action.setStorable();
// Run server-side action
$A.enqueueAction(action);
},

I played with  all attribute maxsize, defaultExpiration but nothing is working out.
If anybody has came across same senario please help.

Many thanks in Advance!!
NagendraNagendra (Salesforce Developers) 
Hi Gaurav,

Please set the expiration parameter (instead of defaultExpiration), everything starts to work as expected. For example, if you want to hold the data for 10 minutes then use something like below.
expiration : 600,
By declaring the above aura will store your data for ten minutes.

Please mark this as best answer if it's resolved.

Best Regards,
Nagendra.P
Gaurav  PuranikGaurav Puranik
Hi Nagendra.,

Thanks for the reply! But I already tried using expiration instead of defaultExpiration it is not allowing me to save the component then.
Please find the attachment. 

User-added image

Thanks Again!!
NagendraNagendra (Salesforce Developers) 
Hi Gaurav,

Check with the below information which might help you a bit in accelerating further.
http://salesforce.stackexchange.com/questions/108570/error-field-integrity-exception-failed-to-save-undefined-no-type-named-apex-t

Best Regards,
Nagendra.P
Gaurav  PuranikGaurav Puranik
Hi Nagendra.,

My org is not having the namespace issue, but the thing is expiration attribute is not there for <aura:auraStorage:init. Please refer the below link.

https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/aura_compref_auraStorage_init.htm
 
I too saw some of the link to resolve the problem but unfortunately I unable to do it, and in documentation also it is not clear. Below are some of the link I am refering but couldn't able to achieve it.

https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/aura_compref_auraStorage_init.htm
http://stackoverflow.com/questions/38434097/aura-storage-keeps-data-for-a-few-seconds-should-keep-for-a-long-time/39663045#39663045

Thanks Again!!
NagendraNagendra (Salesforce Developers) 
Hi Gaurav,

Please check below links and let me know if they were helpful
  • https://developer.salesforce.com/docs/atlas.en-us.202.0.lightning.meta/lightning/storage_init.htm
  • https://developer.salesforce.com/forums/?id=906F0000000kChYIAU
Hope this helps.

Best Regards,
Nagendra.P
Gaurav  PuranikGaurav Puranik
Hi Nagendra.,

- Yes, I have visited these links as well. I visited many links but still couldn't able to implement it.
 
pradeep kumar yadavpradeep kumar yadav
Why you are using auraStorage:init developed component by salesforce, if it did not fulfil your requirement then you can create your own component to store data.

Follow the link and see the code behind auraStorage:init and create your own component to store data.
https://github.com/forcedotcom/aura/tree/master/aura-components/src/main/components/auraStorage/init