diff --git a/README.md b/README.md index 90bca6b3c..4b92ade37 100644 --- a/README.md +++ b/README.md @@ -284,7 +284,7 @@ echo implode('
', $CachedString->get());// Will echo your product list * See the file examples/withoutComposer.php for more information. #### :zap: Step 3: Enjoy ! Your website is now faster than lightning ! -For curious developpers, there is a lot of other examples available [here](https://github.com/PHPSocialNetwork/phpfastcache/tree/final/examples). +For curious developpers, there is a lot of other examples available [here](https://github.com/PHPSocialNetwork/phpfastcache/tree/final/docs/examples). #### :boom: phpFastCache support Found an issue or have an idea ? Come [here](https://github.com/PHPSocialNetwork/phpfastcache/issues) and let us know ! diff --git a/docs/migration/MigratingFromV5ToV6.md b/docs/migration/MigratingFromV5ToV6.md index 0e3a2917d..5abbee0d8 100644 --- a/docs/migration/MigratingFromV5ToV6.md +++ b/docs/migration/MigratingFromV5ToV6.md @@ -8,6 +8,37 @@ Notice: Undefined index: e in /phpfastcache/src/phpFastCache/Core/Pool/DriverBas Fatal error: Uncaught phpFastCache\Exceptions\phpFastCacheInvalidArgumentException: $expiration must be an object implementing the DateTimeInterface in ... ``` +### Setting up a default config + +#### :clock1: Then: +PhpFastCache used to set a default global config using the `CacheManager::setup()` method + +```php +namespace My\Custom\Project; + + +$instance = CacheManager::setup([ + 'path' => 'somewhere' +]); +$instance = CacheManager::getInstance('Files'); + +``` + +#### :alarm_clock: Now: +This method has been changed is now replaced by the `CacheManager::setDefaultConfig()` method. +Using the old `CacheManager::setup()` method will trigger a `phpFastCacheInvalidConfigurationException` + +```php +namespace My\Custom\Project; + + +$instance = CacheManager::setDefaultConfig([ + 'path' => 'somewhere' +]); +$instance = CacheManager::getInstance('Files'); + +``` + ### Type hint of Driver instances #### :clock1: Then: diff --git a/examples/zend_disk.php b/examples/zend_disk.php deleted file mode 100644 index 5b149b2f2..000000000 --- a/examples/zend_disk.php +++ /dev/null @@ -1,48 +0,0 @@ - - * - */ -// Include composer autoloader -require __DIR__ . '/../vendor/autoload.php'; -// OR require_once("../src/phpFastCache/phpFastCache.php"); -date_default_timezone_set("Europe/Paris"); - - -use phpFastCache\CacheManager; -use phpFastCache\Core\phpFastCache; - -// In your class, function, you can call the Cache -$InstanceCache = CacheManager::getInstance('zenddisk'); -// OR $InstanceCache = CacheManager::getInstance() <-- open examples/global.setup.php to see more - -/** - * Try to get $products from Caching First - * product_page is "identity keyword"; - */ -$key = "product_page"; -$CachedString = $InstanceCache->getItem($key); - -if (is_null($CachedString->get())) { - //$CachedString = "Zend Disk Cache --> Cache Enabled --> Well done !"; - // Write products to Cache in 10 minutes with same keyword - $CachedString->set("Zend Disk Cache --> Cache Enabled --> Well done !"); - $InstanceCache->save($CachedString); - - echo "FIRST LOAD // WROTE OBJECT TO CACHE // RELOAD THE PAGE AND SEE // "; - echo $CachedString->get(); - -} else { - echo "READ FROM CACHE // "; - echo $CachedString->getExpirationDate()->format(Datetime::W3C); - echo $CachedString->get(); -} - -echo '

Back to index -- Reload'; \ No newline at end of file diff --git a/examples/zend_shm.php b/examples/zend_shm.php deleted file mode 100644 index 54233a557..000000000 --- a/examples/zend_shm.php +++ /dev/null @@ -1,41 +0,0 @@ - - * - */ -use phpFastCache\CacheManager; - -// Include composer autoloader -require __DIR__ . '/../vendor/autoload.php'; - -$InstanceCache = CacheManager::getInstance('zendshm'); - -/** - * Try to get $products from Caching First - * product_page is "identity keyword"; - */ -$key = "product_page"; -$CachedString = $InstanceCache->getItem($key); - -if (is_null($CachedString->get())) { - //$CachedString = "Zend Memory Cache --> Cache Enabled --> Well done !"; - // Write products to Cache in 10 minutes with same keyword - $CachedString->set("Zend Memory Cache --> Cache Enabled --> Well done !")->expiresAfter(5); - $InstanceCache->save($CachedString); - - echo "FIRST LOAD // WROTE OBJECT TO CACHE // RELOAD THE PAGE AND SEE // "; - echo $CachedString->get(); - -} else { - echo "READ FROM CACHE // "; - echo $CachedString->get(); -} - -echo '

Back to index -- Reload'; diff --git a/src/phpFastCache/CacheManager.php b/src/phpFastCache/CacheManager.php index 46cefad26..7bdd0c711 100644 --- a/src/phpFastCache/CacheManager.php +++ b/src/phpFastCache/CacheManager.php @@ -332,6 +332,18 @@ public static function setDefaultConfig($name, $value = null) } } + /** + * @param $name string|array + * @param mixed $value + * @throws phpFastCacheInvalidConfigurationException + * @deprecated Method "setup" is deprecated, please use "setDefaultConfig" method instead + */ + public static function setup($name, $value = null) + { + throw new phpFastCacheInvalidConfigurationException(sprintf('Method "%s" is deprecated, please use "setDefaultConfig" method instead.', __FUNCTION__)); + } + + /** * @return array */