IDEMPIERE-6000 Reset AD_SysConfig cache automatically when configured (#2196)

* IDEMPIERE-6000 Reset AD_SysConfig cache automatically when configured

* - better comment
This commit is contained in:
Carlos Ruiz 2024-01-17 08:37:25 +01:00
parent a87de727af
commit bf89e009ab
1 changed files with 16 additions and 1 deletions

View File

@ -24,8 +24,10 @@ import java.util.Date;
import java.util.Properties; import java.util.Properties;
import java.util.logging.Level; import java.util.logging.Level;
import org.compiere.Adempiere;
import org.compiere.util.CCache; import org.compiere.util.CCache;
import org.compiere.util.CLogger; import org.compiere.util.CLogger;
import org.compiere.util.CacheMgt;
import org.compiere.util.DB; import org.compiere.util.DB;
import org.compiere.util.DisplayType; import org.compiere.util.DisplayType;
import org.compiere.util.Util; import org.compiere.util.Util;
@ -44,7 +46,7 @@ public class MSysConfig extends X_AD_SysConfig
/** /**
* *
*/ */
private static final long serialVersionUID = 4879268878721712444L; private static final long serialVersionUID = -4149262106340017798L;
/** Constant for Predefine System Configuration Names (in alphabetical order) */ /** Constant for Predefine System Configuration Names (in alphabetical order) */
@ -904,4 +906,17 @@ public class MSysConfig extends X_AD_SysConfig
+"]"; +"]";
} }
@Override
protected boolean afterSave(boolean newRecord, boolean success) {
if (success && newRecord && ! getName().endsWith("_NOCACHE")) {
// Clear cache of AD_SysConfig
// This is to clear the cache of AD_SysConfig when creating a new record
// the reset cache is being called on PO when a record is changed or deleted, but not on new
// NOTE also that reset the specific ID doesn't work because the MSysConfig cache holds a
// String type, and CCache.reset(int) just call reset when the key is not an Integer
Adempiere.getThreadPoolExecutor().submit(() -> CacheMgt.get().reset(Table_Name));
}
return success;
}
} // MSysConfig; } // MSysConfig;