Skip to content

Event listener for Imbo that can be used to cache metadata using one of different cache adapters

License

Notifications You must be signed in to change notification settings

imbo/imbo-metadata-cache

Repository files navigation

Imbo metadata cache

CI

This is an event listener that can be added to Imbo to cache metadata using one of the supported adapters. The event listener currently supports Memcached and APC User Cache.

Installation

composer require imbo/imbo-metadata-cache

Usage

To enable the metadata cache in your Imbo installation you need to add a key to the eventListener part of the configuration:

<?php declare(strict_types=1);
use Imbo\Plugin\MetadataCache\Cache;
use Imbo\Plugin\MetadataCache\EventListener;

return [
    // ...

    'eventListeners' => [
        // ...

        'metadataCache' => function() {
            $memcached = new Memcached();
            $memcached->addServer('localhost', 11211);
            $adapter = new Cache\Memcached($memcached, 'myCacheKeyNamespace');

            // or

            $adapter = new Cache\APCu('myCacheKeyNamespace');

            return new EventListener(['cache' => $adapter]);
        },

        // ...
    ],

    // ...
];

This plugin ships with two different adapters as shown in the example above, APCu and Memcached. APCu requires the apcu pecl extension, and Memcached requires the memcached pecl extension and one or more running memcached servers.

Running integration tests

If you want to run the integration tests you will need a running Memcached service. The repo contains a simple configuration file for Docker Compose that you can use to quickly run a Memcached instance.

If you wish to use this, run the following command to start up the service after you have cloned the repo:

docker-compose up -d

After the service is running you can execute all tests by simply running PHPUnit:

composer run test # or ./vendor/bin/phpunit

License

MIT, see LICENSE.

About

Event listener for Imbo that can be used to cache metadata using one of different cache adapters

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages