Skip to content

some tweaks to the Expression Language cache chapter #3300

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 19, 2013
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions components/expression_language/caching.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@ compiled/evaluated quicker.
The Workflow
------------

Both ``evaluate`` and ``compile`` need to do some things before each can
provide the return values. For ``evaluate``, this overhead is even bigger.
Both :method:`Symfony\\Component\\ExpressionLanguage\\ExpressionLanguage::evaluate`
and ``compile()`` need to do some things before each can provide the return
values. For ``evaluate()``, this overhead is even bigger.

Both methods need to tokenize and parse the expression. This is done by the
Both methods need to tokenize and parse the expression. This is done by the
:method:`Symfony\\Component\\ExpressionLanguage\\ExpressionLanguage::parse`
method. It returns a :class:`Symfony\\Component\\ExpressionLanguage\\ParsedExpression`.
Now, the ``compile`` method just returns the string conversion of this object.
The ``evaluate`` method needs to loop through the "nodes" (pieces of an
Now, the ``compile()`` method just returns the string conversion of this object.
The ``evaluate()`` method needs to loop through the "nodes" (pieces of an
expression saved in the ``ParsedExpression``) and evaluate them on the fly.

To save time, the ``ExpressionLanguage`` caches the ``ParsedExpression`` so
Expand All @@ -40,14 +41,14 @@ in the object using the constructor::

.. note::

The `DoctrineBridge`_ has a ParserCache implementation using the
The `DoctrineBridge`_ provides a Parser Cache implementation using the
`doctrine cache library`_, which gives you caching for all sorts of cache
strategies, like Apc, Filesystem and Apc.
strategies, like Apc, Filesystem and Memcached.

Using Parsed and Serialized Expressions
---------------------------------------

Both ``evaluate`` and ``compile`` can handle ``ParsedExpression`` and
Both ``evaluate()`` and ``compile()`` can handle ``ParsedExpression`` and
``SerializedParsedExpression``::

use Symfony\Component\ExpressionLanguage\ParsedExpression;
Expand Down