I want to build a system which uses rules. These rules will change hourly (i.e. "this rule is effective from 2pm to 6pm"). The rules must support arbitrarily complex logic on just 2-3 pre-defined variables and result in a boolean:
item.a > 10 && item.b == 0 || item.category == FOOTWEAR
These rules will be executed hundreds of times per second so I can't afford the overhead of plain old eval
. I want to reload the current effective ruleset from the database hourly, precompile each rule's logic string and execute it via the quickest method possible. It might look something like this:
class Rule