-- Ken Chou <[email protected]> wrote
(on Tuesday, 25 September 2012, 05:45 PM +0800):
> options 1:
> 
> $cache = Cache\StorageFactory::factory(array(
>     'adapter' => array(
>         'name' => 'Filesystem',
>         'options' => array(
>             'ttl'       => 720000,    // cache with 200 hours
>             'cache_dir' => __DIR__ . '/data/cache',
>         ),
>     ),
>     'plugins' => array(
>         'exception_handler' => array('throw_exceptions' => false),
>     ),
> ));
> 
> works fine.
> 
> but
> options 2:
> 
> $cache = Cache\StorageFactory::factory(array(
>     'adapter' => 'Filesystem',

You realize that you're passing a very different structure to the
factory in this second case, right? Structure needs to be:

    [
        adapter => [
            name => adapter name
            options => [ ... ]
        ]
        plugins => [
            name => [ ...options... ]
        ]
    ]

>     'options' => array(
>         'ttl'       => 720000,    // cache with 200 hours
>         'cache_dir' => __DIR__ . '/data/cache',
>     ),
>     'plugins' => array(
>         'exception_handler' => array('throw_exceptions' => false),
>     ),
> ));
> 
> always use default options.
> 
> 
> 
> 
> *in StorageFactory::factory() *:
> 
> $adapterName = $cfg['adapter'];
> $adapterOptions = null;
> if (is_array($cfg['adapter'])) {
>     //...
> }
> 
> if ($adapterOptions && isset($cfg['options'])) {
>             $adapterOptions = array_merge($adapterOptions, $cfg['options']);
> }
> 
> in options 2 :
> $cfg['adapter'] is string
> and
> $adapterOptions=null
> 
> so that $cfg['options'] will never be used...

-- 
Matthew Weier O'Phinney
Project Lead            | [email protected]
Zend Framework          | http://framework.zend.com/
PGP key: http://framework.zend.com/zf-matthew-pgp-key.asc

-- 
List: [email protected]
Info: http://framework.zend.com/archives
Unsubscribe: [email protected]


Reply via email to