$this->storetype = get_class($store);
$this->perfdebug = (!empty($CFG->perfdebug) and $CFG->perfdebug > 7);
if ($loader instanceof cache_loader) {
- $this->loader = $loader;
- // Mark the loader as a sub (chained) loader.
- $this->loader->set_is_sub_loader(true);
+ $this->set_loader($loader);
} else if ($loader instanceof cache_data_source) {
- $this->datasource = $loader;
+ $this->set_data_source($loader);
}
$this->definition->generate_definition_hash();
$this->staticacceleration = $this->definition->use_static_acceleration();
$this->hasattl = ($this->definition->get_ttl() > 0);
}
+ /**
+ * Set the loader for this cache.
+ *
+ * @param cache_loader $loader
+ */
+ protected function set_loader(cache_loader $loader): void {
+ $this->loader = $loader;
+
+ // Mark the loader as a sub (chained) loader.
+ $this->loader->set_is_sub_loader(true);
+ }
+
+ /**
+ * Set the data source for this cache.
+ *
+ * @param cache_data_source $datasource
+ */
+ protected function set_data_source(cache_data_source $datasource): void {
+ $this->datasource = $datasource;
+ }
+
/**
* Used to inform the loader of its state as a sub loader, or as the top of the chain.
*