Supplement about iBATIS cache use

xiaoxiao2021-03-06  45

In your XML configuration file, every cachemodel element, as follows 1 attribute readonly if not written, default is true, then the cache effect is undoubted, please note that only reading here It is not that the data in the database cannot be changed, but it does not modify its property status after the client gets the object from the cache pool, because the same cache object is obtained by concurrent users. Usually, it is more appropriate. You call the DAO's Query method to use to display, if you modify, you usually create a new Vo (value object), receive the properties of the FORMBEAN (OR DTO), then Update, This does not "change" this original object taken in the "Change" cache, and when the change is changed, the cached flush method has been called to ensure consistency of data objects in the database and cache. Remember, the premise of cache use: Make sure that you are "closed" on your database, you can do it through ibatis, don't call JDBC to update the data table you need to cache. 2 Attributes Serialize, if not, default is false, set it to TRUE to improve the overall application (not just every session) performance. This cache returns a different instance (replica) of the cache object to each session. So each session can securely modify the returned object. Note that readonly must be false. If you set it to true, remember to check two things, one thing is that the object stored in the cache (the POJO you want to query) must be serialization, that is, the serializable interface. If you have a complex object property, it must also meet this rule, and your entire object tree must be serialized. Another thing is to close the latency loading attribute in SQL-Map-Config, that is, lazyload = false because it uses a dynamic proxy mechanism, which agent object is not serializable. Normally this property uses the default value false. The best adaptation of the cache type:

Memory has no unified object reuse mode application, or an application of insufficient memory. The LRU often uses some specific objects during a longer period. FIFO users continue to reference specific queries in a short period of time, which is likely to be no longer used. According to personal practice, use the LRU when the memory is sufficient, otherwise it usually uses Memory (WEAK) to get a good effect.

转载请注明原文地址:https://www.9cbs.com/read-80413.html

New Post(0)