Skip to content

charcoal-core 0.4.0

Compare
Choose a tag to compare
@mcaskill mcaskill released this 05 Jun 15:25
· 47 commits to master since this release

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 MetadataLoaderrequired 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

Added

  • Dependency to locomotivemtl/charcoal-cache
  • DescribableTrait::metadataClass() abstract method for defining the model's metadata class
  • AbstractModel::metadataClass() concrete method as per changes to DescribableTrait
  • Class MetadataConfig for handling config.metadata settings
  • Container entry metadata/config to model service provider for config.metadata settings
  • Container entry metadata/cache to model service provider for customizing the cache pool used by MetadataLoader

Changed

  • Synchronized operations between methods AbstractModel::objType() and DescribableTrait::generateMetadataIdent()
  • AbstractModel::createMetadata() method to use new ::metadataClass() method
  • Breaking: DescribableTrait::loadMetadata() method to use new ::metadataClass() method to delegate metadata class instantiation to MetadataLoader
  • Complete rewrite of MetadataLoader class [2fce5f0...d8c4145]

Fixed

  • Caching of instances of MetadataInterface in MetadataLoader
  • Caching of metadata, loaded from filesystem, in MetadataLoader cache pool