Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unrecognized option "Apc" under "stash.caches.default" #91

Closed
layanto opened this issue Dec 31, 2015 · 8 comments
Closed

Unrecognized option "Apc" under "stash.caches.default" #91

layanto opened this issue Dec 31, 2015 · 8 comments

Comments

@layanto
Copy link
Contributor

layanto commented Dec 31, 2015

With this in config.yml:

stash:
    drivers: [ Apc ]
    registerDoctrineAdapter: true
    Apc:
        namespace: sf_stash_

When doing app/console cache:clear with Symfony 2.8.1, getting this error:
Unrecognized option "Apc" under "stash.caches.default"

@layanto
Copy link
Contributor Author

layanto commented Jan 5, 2016

Did a little investigation, it appears the issue is due to $drivers = array_keys(DriverList::getAvailableDrivers()); in getCachesNode() of Configuration.php not returning Apc.
array:4 [ 0 => "BlackHole" 1 => "Composite" 2 => "Ephemeral" 3 => "FileSystem"]

The odd thing is Apc is listed in available drivers in Profiler.
after - 2 8 - profiler no queries

@layanto
Copy link
Contributor Author

layanto commented Jan 6, 2016

Found the cause! I didn't have Apc enabled from cli apc.enable_cli=1. Symfony app/console cache:clear is via cli while Profiler via php-cgi hence different list of available drivers. Maybe worth adding to docs of StashBundle to enable Apc via cli.

@andrerom
Copy link
Contributor

andrerom commented Jan 6, 2016

Sure, but be aware cache in Apc is not shared between different processes, like cli and "web" process. So essentially you should avoid Apc cache if you need to interact with the same cache pool from cli, ref krakjoe/apcu#136.

@layanto
Copy link
Contributor Author

layanto commented Jan 6, 2016

I think you misunderstood me. I wasn't suggesting to use Stash with Apc from cli. The issue is when you run cache:clear in Symfony from cli, it will clear cache (Symfony's cache, not Stash) and then it will do cache warmup (parsing and caching config files including config.yml). With StashBundle, StashBundle will only register Apc as a valid configuration if at runtime Stash Apc driver isAvailable() returns true. With Apc not enabled in cli, this resulted in error because Stash thinks Apc is not available if you have Stash configured to use Apc and have modified ttl and/or namespace in config.yml.

@layanto
Copy link
Contributor Author

layanto commented Jan 6, 2016

I think there are two options:

  1. Apc must be enabled in cli.
  2. StashBundle not to dynamically at runtime decide what is valid configuration (via Dependency Injection Configuration.php). All configuration options should be available to be used in config.yml and Stash will only use the ones for which the drivers are available. This way having Apc configured will not raise error from cli where Apc is not enabled.

Option 1 clearly easier but is a work around. Option 2 I think is the better solution.

@peschee
Copy link

peschee commented Feb 26, 2016

Strange, I have this

php -v
PHP 7.0.3 (cli) (built: Feb  6 2016 03:16:24) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
    with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies

and

php -i | grep enable_cli
apc.enable_cli => On => On
opcache.enable_cli => Off => Off

but when running the cache:clear command I get the error

 [Symfony\Component\Config\Definition\Exception\InvalidConfigurationException]
  Unrecognized option "Apc" under "stash.caches.default"

EDIT:

In my case, the web version fails as well, on these lines inside the {{Apc.php}} Driver file:

        // HHVM has some of the APC extension, but not all of it.
        if (!class_exists('\APCIterator')) {
            return false;
        }

Running phpinfo() shows that the apcu extension is enabled.

Any ideas?

@layanto
Copy link
Contributor Author

layanto commented Feb 26, 2016

You also need apcu-bc for backward compatibility with php7. This is needed until StashBundle is using the latest Stash library that supports apcu directly.

@peschee
Copy link

peschee commented Feb 29, 2016

@layanto Works, thank you!

@layanto layanto closed this as completed May 3, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants