Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
The ApcBundle provides service and twig extension to manage PHP APC Cache for your Symfony2 project.
PHP
Branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

README.markdown

ApcBundle - A bundle to use and manage APC cache for Symfony2 project

The ApcBundle provides service to set/get/delete and more PHP APC Cache. This bundle now provide a twig extension to manage cache from template

PHP example :

$cache = $this->get('apc_cache');
if(!$cache->exist('my_cache_var')){
    $cache->add('my_cache_value', [ int $ttl ]);
}
echo $cache->get();

TWIG example :

{% if not cache('my_cache_var') %}
    my renderer html code
{% endif %}
{{ cache_save()|raw }}

The ApcBundle also provides a command to clear APC cache from CLI.

Clear opcode cache:

php app/console apc:clear --opcode

Clear user cache:

php app/console apc:clear --user

Installation

Requirements

Check that you have the APC extension installed and enabled on your server (see phpinfo())

Get the bundle

To install the bundle, place it in the vendor/bundles/Kelu95/ApcBundle directory of your project You can do this by adding the bundle as a submodule, cloning it, or simply downloading the source.

git submodule add https://kelu95@github.com/kelu95/ApcBundle.git src/Kelu95/ApcBundle

Add the namespace to your autoloader

If it is the first Kelu95 bundle you install in your Symfony 2 project, you need to add the Kelu95 namespace to your autoloader:

// app/autoload.php
$loader->registerNamespaces(array(
    'Kelu95'           => __DIR__.'/../vendor/bundles',
    // ...
));

Initialize the bundle

To start using the bundle, initialize the bundle in your Kernel:

// app/AppKernel.php
public function registerBundles()
{
    $bundles = array(
        // ...
        new Kelu95\ApcBundle\ApcBundle(),
    );
)

Declare the service

//app\config\config.yml
services: 
    // ...
    apc_cache:
        class: Kelu95\ApcBundle\Controller\Cache
        arguments: [%apc_enabled%,%apc_ttl%]

Add this parameters to your parameters

//app\config\parameters.ini
[parameters]
    ;....
    apc_enabled = true
apc_ttl = 1800

apc_ttl is the default time to live, in second. 1800 : 30 minutes

Something went wrong with that request. Please try again.