1

My user case needs to dynamically create tokens for the logging user. It looks a perfect case for aura storage to store the token results from the server action. From the answer of the question here, it looks the auraStorage is only applicable for template component. Since I need use my component in Lightning communities, there would be no need (and/or no way?) to define a lightning app. Is there a way to utilize auraStorage without template component?

0

The Aura Storage Service only supports caching of serverside actions:

Server-side actions storage is the only currently supported type of storage. Storage for server-side actions caches action response values. The storage name must be actions.

https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/storage_init.htm

Within Communities and the Lightning Experience, the aura storage is already initialized for you and you can just used cached actions directly.

Stored/Cached actions are documented in depth here: https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/controllers_server_storable_actions.htm

  • Cool, thanks a lot for the confirmation, Christian! – Allen Han Jan 19 '17 at 5:43
  • hm..., not sure what's wrong with it. I used action.setStorable() in the javascript controller, with ** "defaultAutoRefreshInterval": "1800" and "defaultExpiration": "1800"**, it did not help. I still saw the Apex controller being called each time. Anyone has working sample to share? – Allen Han Jan 19 '17 at 6:56
  • A storable action will still hit the server in most cases. However, it will return an initial stored value and then hit your callback again with the fresh result. – Christian Carter Jan 20 '17 at 6:38
  • yeah, that's what I observed. Actually the behavior of storable action is a perfect approach for my case. Thanks again for the explanation and confirmation! – Allen Han Jan 20 '17 at 19:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.