igniter/elasticache-bundle

一个为 Symfony 设计的 ElastiCache 绑定包。

安装量: 4,388

依赖者: 0

建议者: 0

安全: 0

星标: 3

关注者: 10

分支: 2

开放问题: 0

类型:symfony-bundle

0.2.2 2015-10-14 18:15 UTC

This package is not auto-updated.

Last update: 2024-09-28 16:45:26 UTC


README

一个为 Symfony 设计的 ElastiCache 绑定包。它也可以用于不在 ElastiCache 中的 Redis 集群。为此,我们使用典型的“主”和“从”命名法,而不是 ElastiCache 的“主”和“读”节点名称。

Codeship Status for ShopIgniter/ElastiCacheBundle Coverage Status

安装

要启用 RedisCache 服务,请将您的服务器添加到 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 }

注意

主主机和端口来自 ElastiCache 的复制组 主端点。请不要使用节点的端点进行写入。同样,请不要使用复制组的主端点作为读取服务器。相反,使用主节点的端点进行读取。

使用

要直接使用,从容器中获取服务。

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

要将它用作 Doctrine 自定义缓存提供者,请使用以下配置。使用别名,您还可以通过这个别名从容器中检索服务。

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"

待办事项