igniter/elasticache-bundle

An ElastiCache Bundle for Symfony.

Installs: 4 344

Dependents: 0

Suggesters: 0

Security: 0

Stars: 3

Watchers: 10

Forks: 2

Open Issues: 0

Type:symfony-bundle

0.2.2 2015-10-14 18:15 UTC

This package is not auto-updated.

Last update: 2024-04-27 14:17:24 UTC


README

An ElastiCache Bundle for Symfony. This could also be used for Redis Clusters that aren't in ElastiCache as well. To that end, we use typical "master" and "slave" nomenclature instead of ElastiCache's "primary" and "read" node names.

Codeship Status for ShopIgniter/ElastiCacheBundle Coverage Status

Installation

To enable the RedisCache service, add your servers to your parameters.yml.

parameters:
    # ...
    cache.redis.servers:
        - { host: primary-write.ng.amazonaws.example.com, port: 6379, master: true, timeout: 5 }
        - { host: primary-read.amazonaws.example.com, port: 6379, timeout: 5 }
        - { host: read-1.amazonaws.example.com, port: 6379, timeout: 5 }

Notes

The Master host and port come from ElastiCache's Replication Group Primary Endpoint. Do not use the node's endpoint for writing. Likewise, do not use the Replication Group's Primary Endpoint as a read server. Instead use the primary node's endpoint for reading.

Usage

To use directly, grab the service from the container.

/** @var \Igniter\ElastiCacheBundle\Cache\RedisCache $cache */
$cache = $this->get('igniter.elasticache.rediscache');
$bar = $cache->fetch('foo');
// ...
$cache->save('foo', $bar);

To use as a Doctrine Custom Cache Provider, use the following in your config. Using aliases, you can also retrieve the service by this alias out of the container.

doctrine_cache:
    aliases:
        cache: my_provider
    custom_providers:
        igniter.elasticache:
            prototype:  "igniter.elasticache.rediscache"
            definition_class: "Igniter\ElastiCacheBundle\DependencyInjection\Definition\RedisCacheDefinition"
    providers:
        my_provider:
            igniter.elasticache:
                namespace: "foo"

ToDo