IDEMPIERE-5279 Improve PO to avoid calling cache reset unnecessarily (#1309)

This commit is contained in:
Carlos Ruiz 2022-04-30 00:16:12 +02:00 committed by GitHub
parent eaaa26774c
commit ef085e72d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 4 deletions

View File

@ -2538,11 +2538,14 @@ public abstract class PO
m_newValues = new Object[size];
m_createNew = false;
}
if (!newRecord) {
Adempiere.getThreadPoolExecutor().submit(() -> CacheMgt.get().reset(p_info.getTableName(), get_ID()));
if (!newRecord)
MRecentItem.clearLabel(p_info.getAD_Table_ID(), get_ID());
} else if (get_ID() > 0 && success)
Adempiere.getThreadPoolExecutor().submit(() -> CacheMgt.get().newRecord(p_info.getTableName(), get_ID()));
if (CacheMgt.get().hasCache(p_info.getTableName())) {
if (!newRecord)
Adempiere.getThreadPoolExecutor().submit(() -> CacheMgt.get().reset(p_info.getTableName(), get_ID()));
else if (get_ID() > 0 && success)
Adempiere.getThreadPoolExecutor().submit(() -> CacheMgt.get().newRecord(p_info.getTableName(), get_ID()));
}
return success;
} // saveFinish

View File

@ -478,4 +478,14 @@ public class CacheMgt
}
}
}
/**
* Is there a cache for this table name?
* @param tableName
* @return boolean
*/
public boolean hasCache(String tableName) {
return m_tableNames.contains(tableName);
}
} // CCache