承接 flownative/redis-sentinel 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

flownative/redis-sentinel

Composer 安装命令:

composer require flownative/redis-sentinel

包简介

Flow Redis cache backend with Sentinel support

README 文档

README

MIT license Packagist Maintenance level: Love

Flow Redis Cache Backend with Sentinel Support

This package provides a Redis cache backend with Sentinel support.

Installation

The package is installed as a regular Flow package via Composer. For your existing project, simply include flownative/redis-sentinel into the dependencies of your Flow or Neos distribution:

    $ composer require flownative/redis-sentinel

Usage

The RedisBackend contained in this package can be used as a drop-in-replacement for the Redis backend provided by the neos/cache package.

For regular use with a standalone Redis server, provide configuration in your Caches.yaml like so:

Flow_Mvc_Routing_Route:
    backend: 'Flownative\RedisSentinel\RedisBackend'
    backendOptions: &redisBackendOptions
        hostname: '%env:REDIS_HOST%'
        password: '%env:REDIS_PASSWORD%'
        port: '%env:REDIS_PORT%'
        database: 0
        timeout: 5
        readWriteTimeout: 0.5

Flow_Mvc_Routing_Resolve:
    backend: 'Flownative\RedisSentinel\RedisBackend'
    backendOptions: *redisBackendOptions
    

Of course you can also set concrete values instead of using environment variables.

Note that you can set two different timeouts:

  • "timeout" (default: 5) specifies the time in seconds to wait while connecting to Redis
  • "readWriteTimeout" (default: 1) specifies the time to wait during a read or write operation

You can specify float numbers as timeout values. For example, use 0.5 for setting the timeout to half a second.

When Redis is running in a high availability setup with Sentinel servers, you need to configure the Redis Backend to access the Sentinel servers instead of the actual Redis nodes.

Depending on your setup, this may look like the following:

Flow_Mvc_Routing_Route:
    backend: 'Flownative\RedisSentinel\RedisBackend'
    backendOptions: &backendOptions
        sentinels:
            - 'redis://10.101.213.145:26379'
            - 'redis://10.101.213.146:26379'
            - 'redis://10.101.213.147:26379'
        service: 'mymaster'
        password: 'a-very-long-password'
        database: 0
        timeout: 0.5
        readWriteTimeout: 0.1

Flow_Mvc_Routing_Resolve:
    backend: 'Flownative\RedisSentinel\RedisBackend'
    backendOptions: *backendOptions
    

Note that "service" is the name of your Redis cluster (which is "mymaster" in most default configurations).

This package will use the same password for all connections, there is currently no support for specifying different passwords for Sentinel and client servers.

Logging

This cache backend will log errors, such as connection timeouts or other problems while communicating with the Redis servers.

If a connection error occurs during a request, it is likely, that more errors of the same type will happen. Therefore, those messages will, by default, be de-duplicated: If the messages of an error is identical with one which already has been logged during the current CLI / web request, it will not be logged another time.

You can disable de-duplication logged errors for debugging purposes by setting the respective backend option to false:

Flow_Mvc_Routing_Route:
    backend: 'Flownative\RedisSentinel\RedisBackend'
    backendOptions:
        database: 0
        
        deduplicateErrors: false

If you don't want errors being logged – for example, because you log errors via the MultiBackend – you can turn off logging for this cache backend:

Flow_Mvc_Routing_Route:
    backend: 'Flownative\RedisSentinel\RedisBackend'
    backendOptions:
        database: 0
        
        logErrors: false

Command Line Tool

This package provides CLI commands which can help debugging configuration or connectivity issues.

redissentinel:list

Displays configuration of Redis Sentinel cache backends, including those backends which are defined as a sub-backend of a Multi Backend.

Screenshot

redissentinel:connect

Tries to connect with the specified cache. If the cache is using a Multi Backend, this command will skip the Multi Backend behavior and instantiate the Redis Sentinel Backend directly. Errors are display and explained, if possible.

Screenshot

Screenshot

Tests

You can adjust the host, port and password used in the functional tests using the environment variables REDIS_HOST, REDIS_PORT and REDIS_PASSWORD.

Credits

This cache backend was developed by Robert Lemke of Flownative, based on the Neos Flow Redis Backend, originally created by Christopher Hlubek and later improved by the Neos core team.

flownative/redis-sentinel 适用场景与选型建议

flownative/redis-sentinel 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 21.11k 次下载、GitHub Stars 达 5, 最近一次更新时间为 2019 年 11 月 27 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 flownative/redis-sentinel 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 flownative/redis-sentinel 我们能提供哪些服务?
定制开发 / 二次开发

基于 flownative/redis-sentinel 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 21.11k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 5
  • 点击次数: 11
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 5
  • Watchers: 2
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-11-27