Add kwargs and caching of commonly computed condition values state.
Review Request #8344 — Created Aug. 25, 2016 and submitted
Condition choices may need to hit the database or perform some other
expensive computation in order to make a match determination. Sometimes
these conditions need the same information, or sometimes a condition
will be used more than once. In these cases, it can be handy for the
implementations of those choices to be able to cache some common state,
like the results of the database queries.This adds a new, optional
value_state_cache
keyword argument to the
get_match_value()
methods, which can be used to populate that cache. The
cache is local to a ConditionSet match run, and does not otherwise
persist.Along with this,
BaseConditionChoice.get_match_value()
and
BaseConditionOperator.matches()
now take a**kwargs
, in order to allow
for future expansion (and to swallow the newvalue_state_cache
argument
for methods that don't need to use it).
Unit tests pass.
Made use of the new caching in an implementation.