Caching and AOP in Mendix: Is there a unified or standardized approach for server-side caching in the Mendix application?

Using Mendix Business Modeler to create web applications is fundamentally different from developing web applications using technologies such as Java / Spring / JSF. But I will try to compare these two questions for this question:

In a Java / Spring based application, I can integrate my application with a third-party Ehcache product for method-level data caching. For example, I can configure ehcache to store the return value for a given method (with a specific lifetime). Whenever this method is called, ecache automatically checks whether the method was previously called with the same parameters, and if the return value is stored in the cache. If so, the method is never executed, and the return value of the cached method is returned instead.

I would like to have the same features in Mendix, but in this case I would cache the Microflow return values. Also, I don't want to be forced to add actions around the place, explicitly telling Microflow to check the cache. I would like to register my Microflows for caching in one central location or just mark each Microflow for caching. In other words, this question is also related to the aspect-oriented programming (AOP) concept in Mendix, as it relates to caching: is there a way to get hooks in a Microflow call so that I can apply operations before and after execution? In my opinion, the same reasons that AOP takes place in Java exist in Mendix.

+5
source share
1 answer

When working with the Mendix application, he tries to do as much as possible for you, in this case, this means that the platform already has an object cache in order to save all objects that need caching. Inside, the Mendix platform uses Ehcache to do this.

However, this cache cannot be affected, as is usually the case in Java / Spring. This is due to all the functions of the Mendix platform, which is already trying to cache all objects as efficiently as possible. <w> Each object that you create is always added to the cache. When working with this object, it remains in the cache until the platform detects that a particular object can no longer be accessed either through the user interface or through the microflow. API calls are also available that instruct the platform to store the object in the cache, regardless of its use. But this does not give you the flexibility you requested.


But, in particular, to your question, my initial answer is: why do you want to cache microflow output?
Objects are already cached in memory, and the client browser only updates the cache when specified. Any objects that you use will be cached. Also, looking at most of the microflows that we use, I don’t think that, most likely, I want to cache the output instead of restarting the microflows. Due to the design of most microflows, I think that most microflows can return slightly different data each time you execute it.

There are many classes of listeners that you can subscribe to on the Mendix platform, which allow you to run something in addition to the default action. But this will require some detailed knowledge of current behavior.
For example, you can override the login action, but if you do not complete all the validations, you can make the login process less secure.

+7
source

Source: https://habr.com/ru/post/1216311/


All Articles