[V5˖] Configuring a fallback driver - PHPSocialNetwork/phpfastcache GitHub Wiki

:warning: Please note that this feature has been removed as of the V8

:warning: It's been replaced by aggregated cluster support, see migration guide


In some case you want to be sure that a fallback cache is available if the main one fails for some reasons. The code is pretty simple:

$InstanceCache = CacheManager::getInstance('redis', [
  'fallback' => 'Files', 
  'path' => 'path/to/write/files/to'
]);

:exclamation: Until the V7 the fallback does not support the override of configuration. Therefore you cannot put Ssdb as a fallback of Redis due to the conflict of the following options:

  • port
  • host
  • password

As of the V7 this will ensure you a completely independant fallback configuration:

$InstanceCache = CacheManager::getInstance('redis', new ConfigurationOption([
  'fallback' => 'Files', 
  'fallback_config' => new ConfigurationOption(/* ... */), 
  'path' => 'path/to/write/files/to'
]));

But Files will work (please note that as of the V6.1 the path configuration can be conflicting).

:bangbang: When the fallback is configured and is triggered an E_USER_WARNING error will be raised to alert you that your project is running in degraded mode.