From f03f2f398805b2dd47688f7f0ead97142fb12a29 Mon Sep 17 00:00:00 2001 From: Alexandre GESLIN Date: Mon, 17 Oct 2016 10:58:20 +0200 Subject: [PATCH] Update caching.rst [ExpressionLanguage] Making cache PSR6 compliant --- components/expression_language/caching.rst | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/components/expression_language/caching.rst b/components/expression_language/caching.rst index b06176a0375..ba35726dfc4 100644 --- a/components/expression_language/caching.rst +++ b/components/expression_language/caching.rst @@ -26,24 +26,21 @@ expression saved in the ``ParsedExpression``) and evaluate them on the fly. To save time, the ``ExpressionLanguage`` caches the ``ParsedExpression`` so it can skip the tokenize and parse steps with duplicate expressions. -The caching is done by a -:class:`Symfony\\Component\\ExpressionLanguage\\ParserCache\\ParserCacheInterface` -instance (by default, it uses an -:class:`Symfony\\Component\\ExpressionLanguage\\ParserCache\\ArrayParserCache`). -You can customize this by creating a custom ``ParserCache`` and injecting this +The caching is done by a `CacheItemPoolInterface`_ instance (by default, it uses an +:class:`Symfony\\Component\\Cache\\Adapter\\ArrayAdapter`). +You can customize this by creating a custom ``Cache`` and injecting this in the object using the constructor:: use Symfony\Component\ExpressionLanguage\ExpressionLanguage; - use Acme\ExpressionLanguage\ParserCache\MyDatabaseParserCache; + use Symfony\Component\Cache\Adapter\RedisAdapter; - $cache = new MyDatabaseParserCache(...); + $cache = new RedisAdapter(...); $language = new ExpressionLanguage($cache); -.. note:: +.. seealso:: - 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 Memcached. + See the :doc:`/components/cache` documentation for more information about + available cache adapters. Using Parsed and Serialized Expressions --------------------------------------- @@ -70,5 +67,4 @@ Both ``evaluate()`` and ``compile()`` can handle ``ParsedExpression`` and var_dump($language->evaluate($expression)); // prints 5 -.. _DoctrineBridge: https://github.com/symfony/doctrine-bridge -.. _`doctrine cache library`: http://docs.doctrine-project.org/projects/doctrine-common/en/latest/reference/caching.html +.. _`CacheItemPoolInterface`: https://github.com/php-fig/cache/blob/master/src/CacheItemPoolInterface.php