Forum Replies Created

  • prabhat

    Member
    February 5, 2019 at 7:20 am in reply to: what is the use of setStorable() in Salesforce?

    Hi Prachi,

    Prior to Winter ’19, to cache data returned from an Apex method, you had to call setStorable() in JavaScript code on every action that called the Apex method. Now you can mark the Apex method as storable (cacheable) and get rid of any setStorable() calls in JavaScript code.

    Marking a method as storable improves your component’s performance by quickly showing cached data from client-side storage without waiting for a server trip. If the cached data is stale, the framework retrieves the latest data from the server. Caching is especially beneficial for users on high-latency, slow, or unreliable connections, such as 3G networks.

    This change is versioned. Existing component code with an API version of 43.0 or earlier continues to work without any changes.

    To cache data returned from an Apex method for any component with an API version of 44.0 or later, annotate the Apex method with @AuraEnabled(cacheable=true).

    For example:

    @AuraEnabled(cacheable=true)
        public static Account getAccount(Id accountId) {
        // your code here
    }

    To update an existing component to API version 44.0, remove setStorable() calls in JavaScript code. Annotate the Apex method with @AuraEnabled(cacheable=true) instead of @AuraEnabled, or you get an error response for the action.

  • Custom setting like as Custom object where you can store your data .

    major difference  is :

    1  - Do not need to Query to access Data We can directly access them using methods 

    2 -
    List custom setting :  Every User can Access
    hierarchy custom setting : restrict data by user by Using ( User Id) .

    3 - No owner is assigned when a custom setting is created

    • This reply was modified 8 years, 5 months ago by  prabhat.

Popular Salesforce Blogs

Popular Salesforce Videos