Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
xabbuh merged 1 commit intosymfony:masterfromxabbuh:pr-6947
Nov 5, 2016
Merged
Show file tree
Hide file tree
Changes fromall 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 deletionscomponents/cache/cache_invalidation.rst
View file
Open in desktop
Original file line numberDiff line numberDiff 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 helpsolve this problem:
The Symfony Cache component provides two mechanisms to helpsolving 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 cacheditems. Each tag is a plain string identifier that you can use at any
time to trigger the removal of all itemsthat had this tag attached to them.
each cacheditem. Each tag is a plain string identifier that you can use at any
time to trigger the removal of all itemsassociated 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 canof coursedelete directly
// if you know the cache key, you canalsodelete the item directly
$cache->deleteItem('cache_key');

Using tags invalidation is very useful when tracking cache keys becomes difficult.
Expand DownExpand 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 deletionscomponents/cache/cache_pools.rst
View file
Open in desktop
Original file line numberDiff line numberDiff 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

[8]ページ先頭

©2009-2025 Movatter.jp