Developed with love by KnpLabs Hire us for your project!
37

CacheToolBundle

by gordalina

CacheTool Symfony2 Bundle

CacheToolBundle

This bundle allows you to integrate CacheTool with Symfony2.

Installation

{
    "require": {
        "gordalina/cachetool-bundle": "~1.0"
    }
}

Register the bundle in app/Appkernel.php:

// app/AppKernel.php

public function registerBundles()
{
    return array(
        // ...
        new CacheTool\Bundle\CacheToolBundle(),
    );
}

Enable the bundle's configuration in app/config/config.yml:

# app/config/config.yml
cache_tool: ~

Configuration

There are two adapters

  1. CLI
# app/config/config.yml
cache_tool:
    adapter: cli
  1. FastCGI
# app/config/config.yml
cache_tool:
    adapter: fastcgi
    fastcgi: 127.0.0.1:900

You can also connect by socket replacing the above by: /var/run/php5-fpm.sock.

If you don’t need apc or opcache you can disable it by setting it to false:

# app/config/config.yml
cache_tool:
    apc: false
# app/config/config.yml
cache_tool:
    opcache: false

Usage

Commands

  cachetool:apc:bin:dump                   Get a binary dump of files and user variables
  cachetool:apc:bin:load                   Load a binary dump into the APC file and user variables
  cachetool:apc:cache:info                 Shows APC user & system cache information
  cachetool:apc:cache:info:file            Shows APC file cache information
  cachetool:apc:key:delete                 Deletes an APC key
  cachetool:apc:key:exists                 Checks if an APC key exists
  cachetool:apc:key:fetch                  Shows the content of an APC key
  cachetool:apc:key:store                  Store an APC key with given value
  cachetool:apc:sma:info                   Show APC shared memory allocation information
  cachetool:cache:clear:dump               Clears APC cache (user, system or all)
  cachetool:opcache:configuration          Get configuration information about the cache
  cachetool:opcache:reset                  Resets the contents of the opcode cache
  cachetool:opcache:status                 Show summary information about the opcode cache
  cachetool:opcache:status:scripts         Show scripts in the opcode cache

Service

You can access all apc and opcode functions through the cachetool service.


$cache = $container->get('cachetool');
$cache->apc_clear_cache('both');
// or
$cache->opcache_reset();

Extending CacheTool

CacheTool depends on Proxies to provide functionality, by default when creating a CacheTool instance from the factory
all proxies are enabled ApcProxy, OpcacheProxy and PhpProxy, you can customize it or extend to your will like the example below:

use CacheTool\Adapter\FastCGI;
use CacheTool\CacheTool;
use CacheTool\Proxy;

$adapter = new FastCGI('/var/run/php5-fpm.sock');
$cache = new CacheTool();
$cache->setAdapter($adapter);
$cache->addProxy(new Proxy\ApcProxy());
$cache->addProxy(new Proxy\PhpProxy());

You can read more information at CacheTool's page.

License

This bundle is released under the MIT license. See the complete license in the bundle.

Copyright (c) 2014 Samuel Gordalina

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
cache_tool:
adapter: fastcgi
apc: true
fastcgi: 127.0.0.1:9000
opcache: true
temp_dir: ~
  • Merge pull request #1 from hacfi/configurable
    By gordalina, 5 years ago
  • Merge pull request #2 from hacfi/clean_up
    By gordalina, 5 years ago
  • Correct configuration root & remove unnecessary $rootNode variable
    By hacfi, 5 years ago
  • Remove default generator headers from DependencyInjection files
    By hacfi, 5 years ago
  • Use lowercase inheritdoc to be more consistent (same as Command classes)
    By hacfi, 5 years ago
  • Fix CacheTool class reference in PhpDoc
    By hacfi, 5 years ago
  • Configuration options to disable apc or opcache - README update
    By hacfi, 5 years ago
  • Configuration options to disable apc or opcache
    By hacfi, 5 years ago
  • Change command name
    By gordalina, 6 years ago
  • Update configuration on README
    By gordalina, 6 years ago
  • require cachetool 1.6.1
    By gordalina, 6 years ago
  • Define cachetool 1.5 as dep
    By gordalina, 6 years ago
  • Add support for CacheTool 1.5
    By gordalina, 6 years ago
  • Fix typo
    By gordalina, 6 years ago
  • Add usage
    By gordalina, 6 years ago
  • Call setAdapter instead of constructor
    By gordalina, 6 years ago
  • Add helper method & container property
    By gordalina, 6 years ago
  • Add keywords
    By gordalina, 6 years ago
  • Add README
    By gordalina, 6 years ago
  • Rename bundle name
    By gordalina, 6 years ago
  • Add getContainer() to Commands
    By gordalina, 6 years ago
  • Add LICENSE and copyright
    By gordalina, 6 years ago
  • Add Command files
    By gordalina, 6 years ago
  • Initial Import
    By gordalina, 6 years ago