Expression Programming Concepts in the Marketing System
The Expression Evaluation Engine (EEE) evaluates expressions. It consists of the evaluation core logic, the ExpressionEvaluator object, caches for loaded expressions, object properties, and expression results. Your code can access the EEE through the MarketingExpressionEvaluator object. The following figure shows the object relationships in the EEE.
Expression Evaluation Engine
The EEE consists of the following parts:
Evaluation context
Evaluation core
Expression cache
Expression result cache
ExpressionEvaluator object
Object property cache
Evaluation Context
An evaluation context evaluates a set of expressions against profiles. Evaluation contexts increase performance because they enable additional EEE intelligent caching. Evaluation contexts enable caching of profile properties and expression results. For example, the CSF CSFEvalTargetGroups component uses evaluation contexts to evaluate targeting expressions against profiles.
An evaluation context object is automatically created if it does not exist when an expression is evaluated. Context objects are automatically released after the expression has been evaluated.
Evaluation Core
The evaluate core handles the evaluation of the expression.
Expression Cache
Expressions are loaded from the expression store into the expression cache. The ExpressionEval object first looks for the expression in this cache when an expression is to be evaluated. The expression is loaded if it cannot be found in the cache. To improve run-time performance, preload expressions into the expression cache by using the LoadExpression or LoadAll methods.
Expression Result Cache
The expression result cache contains the results of each evaluated expression. This enables the result to be returned without the overhead of reevaluating the expression.
ExpressionEvaluator Object
The ExpressionEvaluator object loads and flushes the expression cache, creates the evaluation contexts against which expressions are evaluated, and performs evaluations on expressions.
ExpressionStore Object
The ExpressionStore object interacts with the expression store to create, delete, save, retrieve, query, import, and export expressions.
TargetingContext
To target advertisements or discounts, Commerce Server Core Systems provides two default profile definitions that you can use to build targeting expressions. Alternatively, you can create your own profiles and load them into the following properties:
In Commerce Server Core Systems ASP.NET-based sites, the TargetingContextProfile property represents a true profile object, with a strictly enforced schema. The default TargetingContext profile schema includes a unique key property, unique_id. On each page request, a unique value for this property is automatically generated by the TargetingSystemInfo class.
Object Property Cache
When an expression is first evaluated, references to the dependent profile objects are stored in the object property cache. Object property values are stored in this cache for reuse during evaluation.