public function createCache(Application $app)
    {
        $cache = new Pimple;

        foreach ($app['ems.options'] as $name => $options) {
            $cache[$name] = $cache->share(
                function () use ($app, $cache, $options) {
                    $class = 'Doctrine\Common\Cache\\' . $options['caching_driver'];

                    switch ($options['caching_driver']) {
                        case 'ApcCache':
                        case 'ArrayCache':
                        case 'XcacheCache':
                            return new $class();
                        case 'MemcacheCache':
                            $cache = new $class();

                            if ((false === isset($app['memcache']))
                                    && (false === isset($options['memcache']))) {
                                throw new RuntimeException (
                                    'No Memcache client available as a service.'
                                );
                            }

                            $cache->setMemcache(
                                isset($options['memcache'])
                                    ? $options['memcache']
                                    : $app['memcache']
                            );

                            return $cache;
                        case 'MemcachedCache':
                            $cache = new $class();

                            if ((false === isset($app['memcached']))
                                    && (false === isset($options['memcached']))) {
                                throw new RuntimeException (
                                    'No Memcached client available as a service.'
                                );
                            }

                            $cache->setMemcached(
                                isset($options['memcached'])
                                    ? $options['memcached']
                                    : $app['memcached']
                            );

                            return $cache;
                        default:
                            throw new InvalidArgumentException (
                                "Unsupported cache class: $class"
                            );
                    }
                }
            );
        }

        return $cache;
    }
public function createCache(Application $app)
    {
        $cache = new Pimple;

        foreach ($app['ems.options'] as $name => $options) {
            $cache[$name] = $cache->share(
                function () use ($app, $cache, $options) {
                    $class = 'Doctrine\Common\Cache\\' . $options['caching_driver'];

                    switch ($options['caching_driver']) {
                        case 'ApcCache':
                        case 'ArrayCache':
                        case 'XcacheCache':
                            return new $class();
                        case 'MemcacheCache':
                            $cache = new $class();

                            if ((false === isset($app['memcache']))
                                    && (false === isset($options['memcache']))) {
                                throw new RuntimeException (
                                    'No Memcache client available as a service.'
                                );
                            }

                            $cache->setMemcache(
                                isset($options['memcache'])
                                    ? $options['memcache']
                                    : $app['memcache']
                            );

                            return $cache;
                        case 'MemcachedCache':
                            $cache = new $class();

                            if ((false === isset($app['memcached']))
                                    && (false === isset($options['memcached']))) {
                                throw new RuntimeException (
                                    'No Memcached client available as a service.'
                                );
                            }

                            $cache->setMemcached(
                                isset($options['memcached'])
                                    ? $options['memcached']
                                    : $app['memcached']
                            );

                            return $cache;
                        default:
                            throw new InvalidArgumentException (
                                "Unsupported cache class: $class"
                            );
                    }
                }
            );
        }

        return $cache;
    }
public function createCache ( Application $ app ) { $ cache = new Pimple ; foreach ( $ app [ 'ems.options' ] as $ name => $ options ) { $ cache [ $ name ] = $ cache -> share ( function ( ) use ( $ app , $ cache , $ options ) { $ class = 'Doctrine\Common\Cache\\' . $ options [ 'caching_driver' ] ; switch ( $ options [ 'caching_driver' ] ) { case 'ApcCache' : case 'ArrayCache' : case 'XcacheCache' : return new $ class ( ) ; case 'MemcacheCache' : $ cache = new $ class ( ) ; if ( ( false === isset ( $ app [ 'memcache' ] ) ) && ( false === isset ( $ options [ 'memcache' ] ) ) ) { throw new RuntimeException ( 'No Memcache client available as a service.' ) ; } $ cache -> setMemcache ( isset ( $ options [ 'memcache' ] ) ? $ options [ 'memcache' ] : $ app [ 'memcache' ] ) ; return $ cache ; case 'MemcachedCache' : $ cache = new $ class ( ) ; if ( ( false === isset ( $ app [ 'memcached' ] ) ) && ( false === isset ( $ options [ 'memcached' ] ) ) ) { throw new RuntimeException ( 'No Memcached client available as a service.' ) ; } $ cache -> setMemcached ( isset ( $ options [ 'memcached' ] ) ? $ options [ 'memcached' ] : $ app [ 'memcached' ] ) ; return $ cache ; default : throw new InvalidArgumentException ( "Unsupported cache class: $class" ) ; } } ) ; } return $ cache ; }
Creates the cache instances for the entity managers.

@param Application $app The application.

@return Pimple The cache instance manager.
Creates the cache instances for the entity managers .