Permalink
Browse files

Remove cache shutdown fiddling, this is no longer needed after httpke…

…rnel migration
  • Loading branch information...
flack committed Feb 1, 2019
1 parent 4fe755d commit 0fa7a802675b948ba07e9066d4db2589344c51fc
Showing with 7 additions and 51 deletions.
  1. +0 −6 lib/midcom/application.php
  2. +6 −27 lib/midcom/services/cache/main.php
  3. +1 −18 lib/midcom/services/cache/module.php
@@ -219,16 +219,10 @@ public function dynamic_load($url)
/**
* Exit from the framework, execute after all output has been made.
*
* Does all necessary clean-up work. Must be called after output is completed as
* the last call of any MidCOM Page.
*
* <b>WARNING:</b> Anything done after calling this method will be lost.
*/
public function finish()
{
// Shutdown rest of the caches
$this->cache->shutdown();
debug_add("End of MidCOM run: " . $this->request->server->get('REQUEST_URI'));
_midcom_stop_request();
}
@@ -44,18 +44,10 @@ class midcom_services_cache implements EventSubscriberInterface
/**
* List of all loaded modules, indexed by their class name.
*
* @var Array
* @var midcom_services_cache_module[]
*/
private $_modules = [];
/**
* List of all modules in the order they need to be unloaded. This is a FILO queue, the
* module loaded first is unloaded last.
*
* @var Array
*/
private $_unload_queue = [];
/**
* Cache service startup. It initializes all cache modules configured in the
* global configuration as outlined in the class introduction.
@@ -112,25 +104,13 @@ public function handle_update(dbaevent $event)
}
}
/**
* Shuts all cache modules down. The content module is explicitly stopped as the
* last module for clear content cache handling (it might _midcom_stop_request()).
*/
public function shutdown()
{
foreach ($this->_unload_queue as $name) {
$this->_modules[$name]->shutdown();
}
midcom::get()->dispatcher->removeSubscriber($this);
}
/**
* Load the specified cache module (if not already loaded), add it to the _modules array
* and assign it to a member variable named after the module.
*
* @param string $name The name of the cache module to load.
*/
function load_module($name)
private function load_module($name)
{
if (isset($this->_modules[$name])) {
return;
@@ -145,7 +125,6 @@ function load_module($name)
$this->_modules[$name] = new $classname();
$this->_modules[$name]->initialize();
$this->$name =& $this->_modules[$name];
array_unshift($this->_unload_queue, $name);
}
/**
@@ -156,9 +135,9 @@ function load_module($name)
*/
public function invalidate_all()
{
foreach ($this->_unload_queue as $name) {
foreach ($this->_modules as $name => $module) {
debug_add("Invalidating the cache module {$name} completely.");
$this->_modules[$name]->invalidate_all();
$module->invalidate_all();
}
array_map('unlink', glob(midcom::get()->config->get('cache_base_directory') . 'routing/*'));
connection::invalidate_cache();
@@ -185,13 +164,13 @@ public function invalidate($guid, $skip_module = '')
return;
}
foreach ($this->_unload_queue as $name) {
foreach ($this->_modules as $name => $module) {
if ($name == $skip_module) {
debug_add("We have to skip the cache module {$name}.");
continue;
}
debug_add("Invalidating the cache module {$name} for GUID {$guid}.");
$this->_modules[$name]->invalidate($guid, $object);
$module->invalidate($guid, $object);
}
}
}
@@ -10,7 +10,7 @@
/**
* This is the base class for the MidCOM cache modules. It provides a basic infrastructure
* for building your own caching service, providing hooks for initialization and shutdown.
* for building your own caching service, providing hooks for initialization.
*
* It provides convenience methods to start up the cache module, for example for the creation
* of a cache backend instance. There is no specific initialization done during startup, to
@@ -46,14 +46,6 @@ public function initialize()
$this->_on_initialize();
}
/**
* Shuts the module down. This will call the corresponding event handler
*/
public function shutdown()
{
$this->_on_shutdown();
}
/**
* Creates an instance of the handler described by the configuration passed to
* the function.
@@ -150,15 +142,6 @@ public function _on_initialize()
{
}
/**
* Shutdown handler, called during midcom_application::finish(). Note, that for example
* the page cache will not use this cleanup handler, as it produces a complete html page
* based on a previous request.
*/
public function _on_shutdown()
{
}
/**
* Invalidate the cache completely, dropping all entries. The default implementation will
* drop all entries from all registered cache backends using CacheProvider::flushAll().

0 comments on commit 0fa7a80

Please sign in to comment.