igniter / elasticache-bundle
一个为 Symfony 设计的 ElastiCache 绑定包。
0.2.2
2015-10-14 18:15 UTC
Requires
- php: >=5.5
- doctrine/cache: ~1.3
- doctrine/doctrine-cache-bundle: ~1.0
- psr/log: ~1.0
- symfony/framework-bundle: ~2.4
- symfony/yaml: ~2.4
Requires (Dev)
- phpunit/phpunit: ~4.0
- satooshi/php-coveralls: dev-master
- symfony/expression-language: ~2.4
This package is not auto-updated.
Last update: 2024-09-28 16:45:26 UTC
README
一个为 Symfony 设计的 ElastiCache 绑定包。它也可以用于不在 ElastiCache 中的 Redis 集群。为此,我们使用典型的“主”和“从”命名法,而不是 ElastiCache 的“主”和“读”节点名称。
安装
要启用 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"
待办事项
- 支持 Memcached(带有或没有 AWS 的 ElastiCache 集群客户端 for PHP)。
- 配置验证。