Symfony

Cache & Performance

Cache pools, adapters, tags, cache invalidation, HTTP cache, ESI, Varnish integration

20 preguntas de entrevista·
Mid-Level
1

Which interface does Symfony use to implement the PSR-6 cache system?

Respuesta

Symfony implements the PSR-6 standard through the CacheItemPoolInterface. This interface defines methods getItem(), hasItem(), deleteItem(), save() and clear() for managing cache items. Symfony's Cache component provides several adapters (Redis, Memcached, Filesystem, etc.) that all implement this interface, ensuring interoperability with other PSR-6 compatible PHP libraries.

2

What is the default cache adapter configured in Symfony for the development environment?

Respuesta

In development environment, Symfony uses the ArrayAdapter by default which stores cache in memory. This cache is not persistent between requests, which is ideal for development as it avoids stale cache issues when modifying code. In production, it is recommended to use a persistent adapter like Redis or Memcached for better performance.

3

How to create a custom cache pool in Symfony configuration?

Respuesta

Custom cache pools are defined under the framework.cache.pools key in configuration. Each pool can specify its adapter, default lifetime (default_lifetime), and optionally tags. For example, a 'app.cache.products' pool with RedisAdapter allows managing product cache independently from other data, facilitating targeted invalidation.

4

Which method to use to retrieve a value from cache with a computation callback if missing?

5

What is the main advantage of cache tags in Symfony?

+17 preguntas de entrevista

Domina Symfony para tu próxima entrevista

Accede a todas las preguntas, flashcards, tests técnicos, ejercicios de code review y simuladores de entrevista.

Empieza gratis