Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Fixed ClearCommand and README #1

Merged
merged 1 commit into from

2 participants

@isqad88

No description provided.

@kelu95 kelu95 merged commit 7a656e0 into kelu95:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jun 22, 2012
  1. @isqad88

    fixed ClearCommand and README

    isqad88 authored
This page is out of date. Refresh to see the latest.
Showing with 46 additions and 49 deletions.
  1. +34 −37 Command/ClearCommand.php
  2. +12 −12 README.markdown
View
71 Command/ClearCommand.php
@@ -7,7 +7,7 @@
namespace Kelu95\ApcBundle\Command;
-use Symfony\Bundle\FrameworkBundle\Command\Command as BaseCommand;
+use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputInterface;
@@ -15,51 +15,48 @@
use Symfony\Component\Console\Output\Output;
/**
-* ClearCommand.
-*
-* Lets you clear APC cache user or filehits
-*/
-class ClearCommand extends BaseCommand
-{
- /**
- * @see Command
- */
- protected function configure()
- {
+ * ClearCommand.
+ *
+ * Lets you clear APC cache user or filehits
+ */
+class ClearCommand extends ContainerAwareCommand {
+ /**
+ * @see Command
+ */
+ protected function configure() {
$this
->setDefinition(array())
- ->setDescription('Clear all APC cache user or opcode')
+ ->setDescription('Clear all APC cache user or opcode')
->addOption('opcode', null, InputOption::VALUE_NONE, 'Clear opcode cache')
->addOption('user', null, InputOption::VALUE_NONE, 'Clear user cache')
->setName('apc:clear');
}
/**
- * @see Command
- */
- protected function execute(InputInterface $input, OutputInterface $output)
- {
- if(!$input->getOption('user') && !$input->getOption('opcode')){
- $output->writeln('Error : Cache type option must be --user or --opcode');
- return;
- }
-
- //Define cache type from passed option
- if($input->getOption('user')) $cache_type="user";
- else if($input->getOption('opcode')) $cache_type="opcode";
-
- $cache = $this->container->get('apc_cache'); //get apc_cache service
- $cache->clearAll($cache_type); //clear
-
- //output + logger
- $output_str='APC clear all cache '.$cache_type.' from HOST : '.gethostname();
-
- $logger = $this->container->get('logger'); //get logger service
- $logger->info($output_str);
-
+ * @see Command
+ */
+ protected function execute(InputInterface $input, OutputInterface $output) {
+ if(!$input->getOption('user') && !$input->getOption('opcode')){
+ $output->writeln('Error : Cache type option must be --user or --opcode');
+ return;
+ }
+
+ //Define cache type from passed option
+ if($input->getOption('user')) $cache_type="user";
+ else if($input->getOption('opcode')) $cache_type="opcode";
+
+ $cache = $this->getContainer()->get('apc_cache'); //get apc_cache service
+ $cache->clearAll($cache_type); //clear
+
+ //output + logger
+ $output_str='APC clear all cache '.$cache_type.' from HOST : '.gethostname();
+
+ $logger = $this->getContainer()->get('logger'); //get logger service
+ $logger->info($output_str);
+
$output->writeln($output_str);
}
-
-
+
+
}
View
24 README.markdown
@@ -24,11 +24,11 @@ The ApcBundle also provides a command to clear APC cache from CLI.
Clear opcode cache:
- php app/console apc:clear file
+ php app/console apc:clear --opcode
Clear user cache:
- php app/console apc:clear user
+ php app/console apc:clear --user
## Installation
@@ -39,7 +39,7 @@ Check that you have the APC extension installed and enabled on your server (see
### Get the bundle
-To install the bundle, place it in the `src/Kelu95/ApcBundle` directory of your project
+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
@@ -51,7 +51,7 @@ need to add the `Kelu95` namespace to your autoloader:
// app/autoload.php
$loader->registerNamespaces(array(
- 'Kelu95' => __DIR__.'/../src'
+ 'Kelu95' => __DIR__.'/../vendor/bundles',
// ...
));
@@ -69,19 +69,19 @@ To start using the bundle, initialize the bundle in your Kernel:
)
### Declare the service
-
- //app/config.yml
+
+ //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\config.yml
- parameters:
- // ...
- apc_enabled=true
- apc_ttl=1800
+### 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.