If you are using Doctrine already just use those cache classes.
Add a service to config.yml
:
services:
cache:
class: Doctrine\Common\Cache\ApcCache
And use it in your controller:
if ($fooString = $this->get('cache')->fetch('foo')) {
$foo = unserialize($fooString);
} else {
// do the work
$this->get('cache')->save('foo', serialize($foo));
}
Related Contents:
- Symfony: Clear doctrine cache
- Symfony3 ClassNotFoundException after bundle creation
- Automatic post-registration user authentication
- Is there a built-in way to get all of the changed/updated fields in a Doctrine 2 entity
- On delete cascade with doctrine2
- How to use HTTP cache headers with PHP
- Docker in MacOs is very slow
- Path of assets in CSS files in Symfony 2
- Symfony2 conceptual issue: general bundles vs. specific ones
- Symfony 3.4 Use view inside my bundle
- Doctrine Query Language get Max/Latest Row Per Group
- Memcached vs APC which one should I choose? [closed]
- How to get current route in Symfony 2?
- SF2 form : error Neither the property … nor one of the methods “get
- Symfony2 – creating own vendor bundle – project and git strategy
- Leverage browser caching for 3rd party JS
- Passing data to buildForm() in Symfony 2.8, 3.0 and above
- Symfony2 and date_default_timezone_get() – It is not safe to rely on the system’s timezone settings
- Get service via class name from iterable – injected tagged services
- failed to open stream: HTTP wrapper does not support writeable connections
- A YAML file cannot contain tabs as indentation
- Symfony2 AJAX Login
- How to disable redirection after login_check in Symfony 2
- Use Javascript to access a variable passed through Twig
- Posting JSON objects to Symfony 2
- How to display string that contains HTML in twig template?
- How to setup table prefix in symfony2
- Preventing Caching of CSS Files
- The CSRF token is invalid. Please try to resubmit the form
- PDOException “could not find driver” in php
- Running Composer returns: “Could not open input file: composer.phar”
- Symfony 2 EntityManager injection in service
- Access POST values in Symfony2 request object
- How to access an application parameters from a service?
- Request headers bag is missing Authorization header in Symfony 2?
- Compile a referenced LESS file into CSS with PHP automatically
- Symfony2, Dynamic DB Connection/Early override of Doctrine Service
- How to get the request parameters in Symfony 2?
- Symfony 2.0 getting service inside entity
- Symfony 2 – how to pass data to formBuilder?
- Symfony2 Routing – route subdomains
- What is the best way to notify a user after an access_control rule redirects?
- Why does PHP 7.4 on Windows aborts all command line actions that require user input?
- Warning: “continue” targeting switch is equivalent to “break”. Did you mean to use “continue 2”?
- “Class XXX is not a valid entity or mapped super class” after moving the class in the filesystem
- Accessing Files Relative to Bundle in Symfony2
- Laravel migrations: Class “not found”
- symfony2: how to access service from template
- How to access a different controller from inside a controller Symfony2
- How to give container as argument to services