project-open-data / csv-to-api

Proof of concept to dynamically generate RESTful APIs from static CSVs
http://labs.data.gov/csv-to-api/
325 stars 81 forks source link

Does this assume that APC is running? #2

Closed waldoj closed 12 years ago

waldoj commented 12 years ago

DB_API::cache_get() and DB_API::cache_set() both make calls to APC without first verifying that it's actually running, but instead simply verifies that the relevant APC function exists. I'm pretty sure that this is wrong.

Imagine that APC is disabled in php.ini. The extension is then loaded (in the sense that extension_loaded('apc') would say that it is), and apc_fetch() and apc_store() would both exist, meaning that neither are reliable methods of determining whether APC is running.

As best as I can determine, the most reliable test is this:

if ( !extension_loaded('apc') OR ini_get('apc.enabled') != 1)
{
    // APC is not running
}
else
{
    // APC is running
}

There are two other possibilities, though. One is that you know more about this than I do, and I'm wrong. :) The other is that you want to require APC in order to use this, and simply haven't said so in the README, although your use of function_exists and an alternate method of gathering the data in question indicate that's probably not so.

benbalter commented 12 years ago

c22c829f64517f63556f9879bcbbf55201564c5d fixes.