Skip to content
This repository has been archived by the owner on Jan 8, 2020. It is now read-only.

Create AbstractFactory for Cache #4253

Merged

Conversation

weierophinney
Copy link
Member

We already have Zend\Cache\Service\StorageCacheFactory. However, that is limited to a single cache object based on a single configuration value.

This PR creates Zend\Cache\Service\StorageCacheAbstractFactory, which allows defining configuration for multiple named cache objects:

'caches' => array(
    'Memory' => array(
        'adapter' => 'Memory',
        'plugins' => array('Serializer', 'ClearExpiredByFactor'),
    ),
    'Apc' => array(
        'adapter' => 'apc',
        'plugins' => array(
            'exception_handler' => array('throw_exceptions' => false),
        ),
    ),
),

Cache services are then requested using the prefix 'Cache' and the appropriate configuration key: Cache\Memory, 'Cache\Apc`. (Using a prefix prevents the possibility of naming collisions with other abstract factories.)

This abstract factory:

  • does not conflict with the current factory, as it uses a different configuration key (cache vs caches)
  • is opt-in only (you have to tell your application to use the abstract factory; it is not automatically registered by the MVC)
  • follows the same paradigm as the LoggerAbstractServiceFactory

weierophinney added a commit to weierophinney/zendframework that referenced this pull request Apr 29, 2013
- To prevent collisions with other abstract factories, the logger
  abstract factory should require that, when requesting a service, the
  service name be prefixed. I chose "Logger", as that's the service type
  being requested.
- This complements the approach in zendframework#4253 for cache
  objects.
- Not a BC break, as the LoggerAbstractServiceFactory has not yet been
  released.
- Allows having multiple cache objects by implementing an abstract
  factory.
- When requesting a cache services, prefix with 'Cache\\', but
  configuration omits that prefix for brevity.
mwillbanks pushed a commit that referenced this pull request Apr 30, 2013
@mwillbanks mwillbanks merged commit 16fb236 into zendframework:develop Apr 30, 2013
mwillbanks pushed a commit that referenced this pull request Apr 30, 2013
Created abstract factory for caches …
- Allows having multiple cache objects by implementing an abstract
  factory.
- When requesting a cache services, prefix with 'Cache\', but
  configuration omits that prefix for brevity.

Force service prefix in LoggerAbstractServiceFactory …
- To prevent collisions with other abstract factories, the logger
  abstract factory should require that, when requesting a service, the
  service name be prefixed. I chose Logger, as that's the service type
  being requested.
- This complements the approach in #4253 for cache
  objects.
- Not a BC break, as the LoggerAbstractServiceFactory has not yet been
  released.

[#4254] Remove unneeded annotations …
- per @samsonasik
gianarb pushed a commit to zendframework/zend-cache that referenced this pull request May 15, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants