Skip to content

[V5˖] Extending phpFastCache

Georges.L edited this page Oct 16, 2016 · 1 revision

You can extend a specific driver like this:

<?php
namespace MyCustom\Project;

use phpFastCache\Drivers\Files\Driver as FilesDriver;

/**
 * Class extendsPhpFastCache
 * @package MyCustom\Project
 */
class extendedPhpFastCache extends FilesDriver
{
    public function __construct(array $config = [])
    {
        $config[ 'path' ] = 'your/custom/path/where/files/will/be/written';
        parent::__construct($config);
        /**
         * That's all !! Your cache class is ready to use
         */
    }
}

Or using specific phpFastCacheAbstractProxy class:

<?php
namespace MyCustom\Project;

use phpFastCache\Proxy\phpFastCacheAbstractProxy;

/**
 * Class myCustomCacheClass
 * @package MyCustom\Project
 */
class myCustomCacheClass extends phpFastCacheAbstractProxy
{
    public function __construct($driver = '', array $config = [])
    {
        // setup your config with $config
        // setup your driver with $driver 
        $this->instance = CacheManager::getInstance($driver, $config);
    }
}