定制 alfatraining/cassandra-session-handler-bundle 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

alfatraining/cassandra-session-handler-bundle

Composer 安装命令:

composer require alfatraining/cassandra-session-handler-bundle

包简介

Cassandra Session Handler Bundle for Symfony 4 & 5.4

README 文档

README

This Symfony 4 / 5.4 bundle provides a session handler for saving sessions in Cassandra.

Installation

  1. Add the repository and requirement to composer.json:
    {
        "repositories": [
            {
                "type": "vcs",
                "url": "git@github.com:alfatraining/cassandra-session-handler-bundle.git"
            }
        ],
        "require": {
            "alfatraining/cassandra-session-handler-bundle": "dev-master"
        }
    }
  1. Install the bundle via composer update or composer update nothing if you don't want updates.

  2. Register the bundle in app/AppKernel.php:

    new Alfatraining\CassandraSessionHandlerBundle\AlfatrainingCassandraSessionHandlerBundle(),
  1. Add configuration parameters to your app/config/config.yml (the following shows the bundle defaults) and activate the session handler:
    framework:
        session:
            handler_id:  alfatraining_cassandra_session_handler.cassandra_session_handler

    alfatraining_cassandra_session_handler:
        keyspace:         symfony2_sessions    # Cassandra keyspace to use
        column_family:    sessions             # Cassandra table/column family to use
        session_lifetime: 84600                # session lifetime in seconds
  1. Add parameters to app/config/parameters.yml.dist to configure the Cassandra cluster instance:
    parameters:
        # contact points can be 1) a single node (not advisable for Cassandra)
        cassandra_cluster.contact_points:       localhost
        # or 2) a comma-separated list of nodes (mixed host names / IP addresses possible)
        cassandra_cluster.contact_points:       localhost, 127.0.0.1, 172.18.1.10
        # or 3) a native YAML array
        cassandra_cluster.contact_points:
        - localhost
        - 127.0.0.1
        # of course, you may also write this using the inline style
        cassandra_cluster.contact_points:       [localhost, 127.0.0.1]

        # optionally set the credentials to be used for connecting to the Cassandra cluster
        cassandra_cluster.credentials.username: cassandra
        cassandra_cluster.credentials.password: cassandra

In Symfony 4, you can use an environnement variable which contains comma-separated values as a string :

# services.yaml
parameters: 
    cassandra_cluster.contact_points: '%env(string:CASSANDRA_CLUSTER_HOSTS)%'
# .env.local
CASSANDRA_CLUSTER_HOSTS=10.0.0.1,10.0.0.2,10.0.0.3

Then run composer install again or update your parameters.yml by hand.

  1. Don't forget to actually create the keyspace and the column family. An example of the CQL that's needed can be found in Resources/doc/create_session_keyspace_and_table.sql inside this bundle.

As you can see in the Resources/config/services.yml file you need to pass a Cassandra\Cluster (it's an interface even if it doesn't like one) instance to the session handler upon instantiation. Because the DefaultCluster has a lot of configuration options (for SSL, authentication and a whole lot more – see http://datastax.github.io/php-driver/api/Cassandra/Cluster/class.Builder/ for more information) you may replace this class entirely and just instantiate your own custom cluster class instance. Here's how:

  1. Replace the class name to use in your app/config/config.yml file:
    parameters:
        cassandra_cluster.class: Namespace/To/Your/Own/Class
  1. Take a look at how the bundle's implementation works in Lib/Cassandra/Cluster.php.

alfatraining/cassandra-session-handler-bundle 适用场景与选型建议

alfatraining/cassandra-session-handler-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 37.57k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2019 年 08 月 16 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「symfony」 「bundle」 「session」 「cassandra」 「datastax」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

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

围绕 alfatraining/cassandra-session-handler-bundle 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-08-16