charcoal-core 0.4.0
Key Features
New Metadata Loader Class
The MetadataLoader
class suffered from design flaws which resulted in poor performance on large projects.
Metadata Caching
Previously, the MetadataLoader
would store MetadataInterface
instances into the cache pool with the belief the pool would return those same instances. Unfortunately, depending on the cache driver, the instances would be serialized when stored and unserialized into new objects when retrieved. This would cause the cache to miss every time.
This is resolved by storing MetadataInterface
instances in a static class property (MetadataLoader::$metadataCache
) and storing only the raw data in the cache pool.
Metadata Creation
Previously, the MetadataLoader
required a MetadataInterface
instance every time the Loader was called upon to retrieve metadata from the cache (or from the file system). If the data was retrieved from the cache pool, the given instance would be ignored in favour of the instance returned by the pool. This lead to a lot of unnecessary object instantiations.
This is resolved by delegating the instantiation of the MetadataInterface
class to the MetadataLoader
.
New Metadata Config Class
The MetadataConfig
allows one to customize the MetadataLoader
service. The configset stores the Loader's settings, search paths, and cache pool preference.
For an example of a customized Loader, locomotivemtl/charcoal-admin v0.12.x takes advantage of this feature to append extra "admin-only" metadata paths and swap the cache pool.
BC Breaks
Describable Classes:
The DescribableTrait::loadMetadata()
method uses a new DescribableTrait::metadataClass()
method instead of DescribableTrait::createMetadata()
Renamed Methods:
Before | After |
---|---|
MetadataLoader::classnameToIdent |
metaKeyFromClassName |
MetadataLoader::identToClassname |
classNameFromMetaKey |
MetadataLoader::filenameFromIdent |
filePathFromMetaKey |
MetadataLoader::loadData |
loadMetadataByKey |
MetadataLoader::loadDataArray |
loadMetadataByKeys |
MetadataLoader::loadFileFromIdent |
loadMetadataFromSource |
What's new in 0.4.0?
Dependencies
- locomotivemtl/charcoal-config v0.9.x
- locomotivemtl/charcoal-property v0.7.x
- locomotivemtl/charcoal-view v0.3.x
Added
- Dependency to locomotivemtl/charcoal-cache
DescribableTrait::metadataClass()
abstract method for defining the model's metadata classAbstractModel::metadataClass()
concrete method as per changes toDescribableTrait
- Class
MetadataConfig
for handlingconfig.metadata
settings - Container entry
metadata/config
to model service provider forconfig.metadata
settings - Container entry
metadata/cache
to model service provider for customizing the cache pool used byMetadataLoader
Changed
- Synchronized operations between methods
AbstractModel::objType()
andDescribableTrait::generateMetadataIdent()
AbstractModel::createMetadata()
method to use new::metadataClass()
method- Breaking:
DescribableTrait::loadMetadata()
method to use new::metadataClass()
method to delegate metadata class instantiation toMetadataLoader
- Complete rewrite of
MetadataLoader
class [2fce5f0...d8c4145
]
Fixed
- Caching of instances of
MetadataInterface
inMetadataLoader
- Caching of metadata, loaded from filesystem, in
MetadataLoader
cache pool