cache-service-provider icon indicating copy to clipboard operation
cache-service-provider copied to clipboard

Move factories to be plain protected closures which return a cache

Open CHH opened this issue 9 years ago • 0 comments

Currently the cache.factory and the cache.namespace services are protected closures, which return closures, which then return a cache instance. Change these services to be just protected closures, which return a cache instance to reduce complexity and bring it in line with conventions.

Before:

$app['caches'] = $app->extend('caches', function ($caches) use ($app) {
    $caches['foo'] = $app['cache.namespace']('foobar');
    return $caches;
});

After:

$app['caches'] = $app->extend('caches', function ($caches) use ($app) {
    $caches['foo'] = function () use ($app) {
        return $app['cache.namespace']('foobar');
    };
    return $caches;
});

CHH avatar Nov 22 '16 15:11 CHH