I'm building a Lightning Component that relies on heavy pulling of data from server side. but also has Filters.

I was thinking to make use of setStorable() action for pulling data from Apex.

Now, my initial tests worked fine, but it seems erratic at multiple times, when I use filters to filter the list.

As I see it, that inconsistency is due to data being pulled from Cache, but not server side. And it seems, I need to hook into the actions and verify if I should reload from cache or not. And to do that, I need to find out, whether the particular Action has already been cached or not. So can we detect if the action already has been cached, and needs to be refreshed, since filters have changed?

  • The platform should automatically do it for you and if not this is a bug then that you should need support on . – Mohith Shrivastava Mar 19 '18 at 14:54

Storable actions should be idempotent, meaning each time the action is called with the same parameters, it should return the same data. If this is not the case, storable is probably not a good choice for you. You should only set ignoreExisting to true when you know the data has been invalidated because of record changes, as mentioned in the documentation:

Most server requests are read-only and idempotent, which means that a request can be repeated or retried as often as necessary without causing data changes. The responses to idempotent actions can be cached and quickly reused for subsequent identical actions.

If you're doing filtering, you should consider doing client-side filtering as a matter of performance. Here's a gist that shows filtering on a freeform text field, and another based on a list of account cities. If there's a large number of records, you might consider implementing your own caching strategy. For example, if you're filtering on each key stroke, and I type in h, you might go to the server to get all values that have h, and then if I type he, you can filter the list of h records client-side (because all records containing he also contain h, so you've already retrieved the data). Implementing your own custom pseudo-cache might be more efficient than using storable.

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.