Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[#6947] some minor tweaks #7075

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
Nov 5, 2016
Merged
Show file tree
Hide file tree
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
24 changes: 14 additions & 10 deletions 24 components/cache/cache_invalidation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,22 @@ change in the state of your model. The most basic kind of invalidation is direct
items deletion. But when the state of a primary resource has spread accross
several cached items, keeping them in sync can be difficult.

The Symfony Cache component provides two mechanisms to help solve this problem:
The Symfony Cache component provides two mechanisms to help solving this problem:

* Tags based invalidation for managing data dependencies;
* Expiration based invalidation for time related dependencies.
* :ref:`Tags based invalidation <cache-component-tags>` for managing data dependencies;
* :ref:`Expiration based invalidation <cache-component-expiration>` for time related dependencies.

.. versionadded:: 3.2
Tags based invalidation was introduced in Symfony 3.2.
.. _cache-component-tags:

Using Cache Tags
----------------

.. versionadded:: 3.2
Tags based invalidation was introduced in Symfony 3.2.

To benefit from tags based invalidation, you need to attach the proper tags to
each cached items. Each tag is a plain string identifier that you can use at any
time to trigger the removal of all items that had this tag attached to them.
each cached item. Each tag is a plain string identifier that you can use at any
time to trigger the removal of all items associated with this tag.

To attach tags to cached items, you need to use the
:method:`Symfony\\Component\\Cache\\CacheItem::tag` method that is implemented by
Expand All @@ -36,14 +38,14 @@ cache items, as returned by cache adapters::
$item->tag(array('tag_2', 'tag_3'));
$cache->save($item);

If ``$cache`` implements :class:`Symfony\\Component\\Cache\\TagAwareAdapterInterface`,
If ``$cache`` implements :class:`Symfony\\Component\\Cache\\Adapter\\TagAwareAdapterInterface`,
you can invalidate the cached items by calling
:method:`Symfony\\Component\\Cache\\TagAwareAdapterInterface::invalidateTags`::
:method:`Symfony\\Component\\Cache\\Adapter\\TagAwareAdapterInterface::invalidateTags`::

// invalidate all items related to `tag_1` or `tag_3`
$cache->invalidateTags(array('tag_1', 'tag_3'));

// if you know the cache key, you can of course delete directly
// if you know the cache key, you can also delete the item directly
$cache->deleteItem('cache_key');

Using tags invalidation is very useful when tracking cache keys becomes difficult.
Expand Down Expand Up @@ -78,6 +80,8 @@ your fronts and have very fast invalidation checks::
new RedisAdapter('redis://localhost')
);

.. _cache-component-expiration:

Using Cache Expiration
----------------------

Expand Down
6 changes: 3 additions & 3 deletions 6 components/cache/cache_pools.rst
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ See the method's docblock for more options.
PDO & Doctrine DBAL Cache Adapter
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. versionadded:: 3.2
The PDO & Doctrine DBAL adapter was introduced in Symfony 3.2.

This adapter stores the cached items a SQL database accessed through a PDO or a
Doctrine DBAL connection::

Expand All @@ -130,9 +133,6 @@ Doctrine DBAL connection::
$options = array()
);

.. versionadded:: 3.2
The PDO & Doctrine DBAL adapter was introduced in Symfony 3.2.

Chain Cache Adapter
~~~~~~~~~~~~~~~~~~~

Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.