If you include files[] = filecache.inc in the .info file, users won't need to add $conf['cache_backends'] = array('sites/all/modules/contrib/filecache/filecache.inc'); to their settings file.

Comments

ogi’s picture

Status: Active » Closed (works as designed)

files[] are registered for autoloading in _drupal_bootstrap_database() after _drupal_bootstrap_page_cache(). File Cache should be available for page caching and this is one of the reasons why cache_backends exists.

patrickharris’s picture

Strange - I was using it just for page caching successfully using this method.

ogi’s picture

Status: Closed (works as designed) » Active

This is interesting, I'll investigate it.

Anyway, adding $conf['cache_default_class'] = 'DrupalFileCache'; to settings.php is still needed and so editing settings.php can't be avoided.

patrickharris’s picture

These $conf variables can be set by variable_set() rather than hard coded in the settings.php file.

I've written a filecache just for the page cache ('cache_page') which stores files like boost so pages are directly loaded by the server, and php isn't loaded. I just use variable_set('cache_class_cache_page', 'MyFileCache'); in a module, and a files[] = filecache.inc in the .info file.

ogi’s picture

Status: Active » Closed (works as designed)

The order of bootstrap phases is the following (defined in drupal_bootstrap()):

  static $phases = array(
    DRUPAL_BOOTSTRAP_CONFIGURATION,
    DRUPAL_BOOTSTRAP_PAGE_CACHE,
    DRUPAL_BOOTSTRAP_DATABASE,
    DRUPAL_BOOTSTRAP_VARIABLES,
    DRUPAL_BOOTSTRAP_SESSION,
    DRUPAL_BOOTSTRAP_PAGE_HEADER,
    DRUPAL_BOOTSTRAP_LANGUAGE,
    DRUPAL_BOOTSTRAP_FULL,
  );

_drupal_bootstrap_page_cache checks if page_cache_without_database variable is set, and if it's not (this is the default), the following functions are invoked before continuing with page cache:

So what you suggest is true only for default settings but I want File Cache to be able to serve pages without DB and so it's better to use the intended way to do it, with cache_backends.

patrickharris’s picture

Oh of course, if you want to avoid loading the DB it would have to be in settings - good point. Thanks for explaining that!

ogi’s picture

Status: Closed (works as designed) » Needs work

On second thought, it's a nice feature to just install filecache module and have a working File Cache. Less technical people need this, so this will be in 1.0. Just need to be careful to not filecache cache_bootstrap bin because lookup_cache cid contains autoloading info. And if there's any manual setting in cache_* variables, this automation should not be used.

Thank you for this nice suggestion :-)

ogi’s picture

Status: Needs work » Active
ogi’s picture

Note to myself: cache bin should not be filecache:d too because automated cache_* variables are stored there.

ogi’s picture

Status: Active » Closed (won't fix)

Thinking about this again, I see that avoiding editting of settings.php is not worth it. cache and cache_bootstrap bins can't be handled in this case and this devalues the whole idea of easy installation with major impact. AFAIK all other cache modules require editing settings.php.