What are the best practices for lazy loading? #612
-
Assumption that an expression is dynamic, so not all the required data is known in advance. Example: If fetch for I think it's a very normal case in business projects.For example, in a marketing system, the combination of conditions can be very flexible, and the data sources for these conditions include basic account information, order information, login information, and so on. Different combinations of conditions require fetching different combinations of entities(Account, Order , Login...). Pre-fetching all the data every time would result in wastage of resources. It is desired to dynamically retrieve the data sources when evaluating a specific condition and cache the data sources to the environment (env). |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
@antonmedv Could you please kindly provide some suggestions ? |
Beta Was this translation helpful? Give feedback.
-
@BubbleGarten @antonmedv A way to do it without patching is to replace all dynamically populated variables by 'getter's. Static variables can be used as is. |
Beta Was this translation helpful? Give feedback.
@BubbleGarten @antonmedv A way to do it without patching is to replace all dynamically populated variables by 'getter's. Static variables can be used as is.
Thus, the expression becomes :
getFoo() + getBar() + baz
. You can have an arbitrary amount of intelligence in the getters to decide whether you want to download content or use a local cache or something else.