Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace ManifestCache with PSR-16 #6647

Closed
chillu opened this issue Feb 23, 2017 · 4 comments
Closed

Replace ManifestCache with PSR-16 #6647

chillu opened this issue Feb 23, 2017 · 4 comments

Comments

@chillu
Copy link
Member

chillu commented Feb 23, 2017

Follow up from #6252. These caches were kept separate from Zend_Cache because we needed to instanciate them before the app had a chance to configure anything. The only way to configure a ManifestCache is through an SS_MANIFESTCACHE class name.

I suggest we replace this with standard symfony/cache, and make them configurable by manually setting injector services during a customised boot process (e.g. a custom main.php). Sam's got some ideas regarding an App object which feeds into this approach.

Roughly speaking, this would be the content of an index.php with custom caches:

require_once __DIR__ . '../vendor/autoload.php';

use Psr\SimpleCache\CacheInterface;
use Symfony\Component\Cache\Simple\MemcachedCache;
use SilverStripe\Core\DefaultAppFactory;
use SilverStripe\Control\DefaultRequestFactory;

$app = DefaultAppFactory::create();

// custom
$memcached = new Memcached();
$app->setService(new MemcachedCache(
  $memcached,
  'thememanifest',
), CacheInterface::class . '.thememanifest');
$app->setService(new MemcachedCache(
  $memcached,
  'classmanifest',
), CacheInterface::class . '.classmanifest');
$app->setService(new MemcachedCache(
  $memcached,
  'configmanifest',
), CacheInterface::class . '.configmanifest');

$request = DefaultRequestFactory::create();
$response = $app->getDirector()->direct($request);
$response->output();

There's some new bits in here (e.g. DefaultAppFactory) which should be solved first, in a separate ticket.

@tractorcow
Copy link
Contributor

You could also inject custom code with a files composer-included file. This is the same way that framework injects Constants.php (even when running in other apps, e.g. phpunit).

@chillu
Copy link
Member Author

chillu commented Mar 7, 2017

Related: #3940

@tractorcow tractorcow self-assigned this Mar 14, 2017
@marcello-silverstripe marcello-silverstripe added this to the CMS 4.0.0-beta1 milestone Mar 14, 2017
@tractorcow
Copy link
Contributor

PR at #6706

@sminnee sminnee modified the milestones: CMS 4.0.0-alpha6, CMS 4.0.0-beta1 Mar 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants