Described clearing caches in more detail#3289
Conversation
Preview of modified filesPreview of modified Markdown: |
Summary
|
| ### Using the cache service | ||
|
|
||
| Example usage of the cache service: | ||
|
|
||
| ``` php | ||
| use Symfony\Component\Cache\Adapter\TagAwareAdapterInterface; | ||
| use Symfony\Component\DependencyInjection\ContainerInterface; | ||
|
|
There was a problem hiding this comment.
Rewrote this to avoid getting a service from the container directly - that's not recommended anymore
| If you have customized the persistence cache configuration, the name of your cache pool might be different. | ||
|
|
||
| Persistence cache prefixes it's cache using "ibx-". Clearing persistence cache can thus be done in the following ways: | ||
| Persistence cache uses the `ibx-` prefix, declared as a container parameter called `ibexa.core.persistence.cache.tag_prefix`. |
There was a problem hiding this comment.
https://github.com/ibexa/core/blob/6.0/src/lib/Resources/settings/storage_engines/cache.yml#L13
The part about clearing the cache with the command was out of place here, it's about API usage.
Added a link for people searching how to clear the cache manually.
| Manual cache clearing should be executed with caution, as it doesn't warm up the cache. | ||
| It results in a significant performance drop on first request, so it shouldn't be called on a production environment. | ||
| Besides, it could lead to issues with file ownership after running `cache:clear` as a root. | ||
| See [Cache clearing](devops.md#cache-clearing) for information how to clear system, application, and HTTP caches. |
There was a problem hiding this comment.
No need to have this info duplicated in two places.
|
|
||
| ## Web Debug Toolbar | ||
|
|
||
| As of [[= product_name =]] v4.5, the [Symfony Web Debug Toolbar]([[= symfony_doc =]]/profiler.html) is no longer installed by default. | ||
| To install it, run the following command: | ||
|
|
||
| ```bash | ||
| composer require symfony/debug-pack | ||
| composer require --dev symfony/debug-pack |
There was a problem hiding this comment.
--dev was missing, and it's crucial!
|
|
||
| ### Clearing content cache on a cluster setup | ||
| ### Clear HTTP cache |
There was a problem hiding this comment.
Added a dedicated HTTP cache section to cover all types of caches.
| use Symfony\Component\Cache\Adapter\TagAwareAdapterInterface; | ||
| use Symfony\Component\DependencyInjection\ContainerInterface; | ||
|
|
||
| // Getting the cache service in PHP |
There was a problem hiding this comment.
ibexa.cache_pool is a private service (Public: no) so it's not possible to retrieve it from the container anymore
~/Desktop/Sites/v5 main +1 !174 ?19 ❯ php bin/console debug:container ibexa.cache_pool 24.4.0 13:21:18
// This service is a private alias for the service
// Ibexa\Core\Persistence\Cache\Adapter\TransactionalInMemoryCacheAdapter
Information for Service "Ibexa\Core\Persistence\Cache\Adapter\TransactionalInMemoryCacheAdapter"
================================================================================================
Internal proxy adapter invalidating our isolated in-memory cache, and defer shared pool changes during transactions.
---------------- ---------------------------------------------------------------------------------------------------------------------------------
Option Value
---------------- ---------------------------------------------------------------------------------------------------------------------------------
Service ID Ibexa\Core\Persistence\Cache\Adapter\TransactionalInMemoryCacheAdapter
Class Ibexa\Core\Persistence\Cache\Adapter\TransactionalInMemoryCacheAdapter
Tags container.decorator (id: ibexa.cache_pool, inner: Ibexa\Core\Persistence\Cache\Adapter\TransactionalInMemoryCacheAdapter.inner)
Public no
Synthetic no
Lazy yes
Shared yes
Abstract no
Autowired no
Autoconfigured no| This can shortly be described as a cache which is invisible to the end user (admin/editors) of [[= product_name =]] where content is always returned *fresh*. | ||
| In other words, there should be no need to manually clear the cache like it was frequently the case with eZ Publish 4.x. | ||
| This is possible thanks to an interface that follows CRUD (Create Read Update Delete) operations per domain. | ||
| With the persistence cache, like with the HTTP cache, [[= product_name =]] follows the principles of transparent caching. |
There was a problem hiding this comment.
Removed an outdated eZ Publish 4.x mention 🙈
| ``` | ||
|
|
||
| The default cache pool is named `cache.tagaware.filesystem`. | ||
| The default cache pool when running Redis or Valkey is named `cache.redis`. |
There was a problem hiding this comment.
Added to the allowlist in https://github.com/ibexa/vale-styles/pull/44
| php bin/console --env=prod cache:clear | ||
| ``` | ||
|
|
||
| If you don't specify an environment, by default `cache:clear` clears the cache for the `dev` environment. |
There was a problem hiding this comment.
Not entirely correct AFAIR. If you set APP_ENV=prod, by default it should clear prod env. If you ssh into an e.g., Upsun instance, that variable will be set by default.
There was a problem hiding this comment.
https://youtu.be/hou0lU8WMgo 😄
Thanks, nice catch! Clarified (hopefully) in 253fa6b
julitafalcondusza
left a comment
There was a problem hiding this comment.
Just a small remark.
|
|
||
| The default cache pool is named `cache.tagaware.filesystem`. | ||
| The default cache pool when running Redis or Valkey is named `cache.redis`. | ||
| If you have customized the persistence cache configuration, the name of your cache pool might be different. |
There was a problem hiding this comment.
To avoid Present Perfect:
| If you have customized the persistence cache configuration, the name of your cache pool might be different. | |
| If you customized the persistence cache configuration, the name of your cache pool might be different. |
or
| If you have customized the persistence cache configuration, the name of your cache pool might be different. | |
| If your persistence cache configuration is customized, the name of your cache pool might be different. |
Target: 4.6, 5.0, 6.0
As reported on Slack:
This PR clarifies the types of caches and how to clear them.
In addition, I've cleaned up outdated content in the Persistence Cache article - mentioned in comments.
The goal is to have a single "how to clear caches from CLI" article we can use.