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

Detect if APCu is enabled #43

Closed
heruan opened this issue Sep 22, 2013 · 4 comments
Closed

Detect if APCu is enabled #43

heruan opened this issue Sep 22, 2013 · 4 comments

Comments

@heruan
Copy link

heruan commented Sep 22, 2013

How to detect if APCu is enabled? I have a factory method which takes care of providing the best cache instance available. Weather I run it from Apache or CLI, I need to detect if ACPu is enabled. With the former APC I could check it with function_exists('apc_fetch') or class_exists('APCIterator') but now they return true even if apc.enabled and/or apc.enable_cli are set to false.

@nsams
Copy link

nsams commented Sep 24, 2013

I use extension_loaded('apcu')

though that won't help for enable_cli=false I guess.

@krakjoe
Copy link
Owner

krakjoe commented Sep 24, 2013

I've seen this by the way, super busy at the minute ... thinking about it ...

@remicollet
Copy link
Collaborator

Here is an example, used in ZendFramework

    if (version_compare('3.1.6', phpversion('apc')) > 0) {
        throw new Exception\ExtensionNotLoadedException("Missing ext/apc >= 3.1.6");
    }

    $enabled = ini_get('apc.enabled');
    if (PHP_SAPI == 'cli') {
        $enabled = $enabled && (bool) ini_get('apc.enable_cli');
    }

    if (!$enabled) {
        throw new Exception\ExtensionNotLoadedException(
            "ext/apc is disabled - see 'apc.enabled' and 'apc.enable_cli'"
        );
    }

This seems a bit uggly.
Of course a nice API for this could be interesting (except for the time it will require to be adopted...)

@krakjoe
Copy link
Owner

krakjoe commented Sep 24, 2013

Good point, APCu versions start at 4, thanks @remicollet

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

4 participants