m6web/cassandra-bundle
最新稳定版本:v3.0.0
Composer 安装命令:
composer require m6web/cassandra-bundle
包简介
Symfony2 bundle on top of datastax/php-driver
关键字:
README 文档
README
The CassandraBundle provide a Cassandra client as a Symfony service.
Installation
NOTE : You need to install the offical datastax php driver extension
Use composer:
composer require m6web/cassandra-bundle
Then make sure the bundle is registered in your application:
// config/bundles.php return [ \M6Web\Bundle\CassandraBundle\M6WebCassandraBundle::class => ['all' => true], ];
Usage
Add the m6web_cassandra section in your configuration file. Here is the minimal configuration required.
m6web_cassandra: clients: myclient: contact_endpoints: - 127.0.0.1 - 127.0.0.2 - 127.0.0.3
Then you can ask container for your client :
$cassandra = $this->get('m6web_cassandra.client.myclient'); $prepared = $cassandra->prepare("INSERT INTO test (id, title) VALUES(?, ?)"); $batch = new Cassandra\BatchStatement(Cassandra::BATCH_LOGGED); $batch->add($prepared, ['id' => 1, 'title' => 'my title']); $batch->add($prepared, ['id' => 2, 'title' => 'my title 2']); $cassandra->execute($batch); $statement = new Cassandra\SimpleStatement('SELECT * FROM test'); $result = $cassandra->execute($statement); foreach ($result as $row) { // do something with $row } $statement = new Cassandra\SimpleStatement('SELECT * FROM test'); $result = $cassandra->executeAsync($statement); // do something while cassandra query running foreach($result->get() as $row) { // do something with row }
Bundle provide a util class for extracting Datetime from a timeuuid string.
use M6Web\Bundle\CassandraBundle\Cassandra\Type as TypeUtils; $datetime = TypeUtils::getDateTimeFromTimeuuidString('513a5340-6da0-11e5-815e-93ec150e89fd'); if (is_null($datetime)) { // something is wrong with supplied uuid } else { echo $datetime->format(\DateTime::W3C); // 2015-10-08 11:38:22+02:00 }
DataCollector
Datacollector is available when the symfony profiler is enabled. The collector allows you to see the following Cassandra data :
- keyspace
- command name
- command arguments
- execution time
- execution options override (consistency, serial consistency, page size and timeout)
NOTE : The time reported in the data collector may not be the real execution time in case you use the async calls : executeAsync and prepareAsync
Configuration reference
m6web_cassandra: dispatch_events: true # By default event are triggered on each cassandra command clients: client_name: persistent_sessions: true # persistent session connection keyspace: "mykeyspace" # default is null, optional keyspace to connect load_balancing: "round-robin" # round-robin or dc-aware-round-robin dc_options: # required if load balancing is set to dc-aware-round-robin local_dc_name: "testdc" host_per_remote_dc: 3 remote_dc_for_local_consistency: false default_consistency: "one" # 'one', 'any', 'two', 'three', 'quorum', 'all', 'local_quorum', 'each_quorum', 'serial', 'local_serial', 'local_one' default_pagesize: 10000 # ~ to disable pagination contact_endpoints: # required list of ip to contact - 127.0.0.1 contact_whitelist: # if specified cassandra will connect only to this datacenters/hosts dc: - "testdc" host: - 172.0.0.1 contact_blacklist: # if specified cassandra will not connect to this datacenters/hosts dc: - "blacklisted_testdc" host: - 6.6.6.6 port_endpoint: 9042 # cassandra port token_aware_routing: true # Enable or disable token aware routing credentials: # cassandra authentication username: "" # username for authentication password: "" # password for authentication ssl: false # set up ssl context default_timeout: null # default is null, must be an integer if set timeout: connect: 5 request: 5 retries: sync_requests: 0 # Number of retries for synchronous requests. Default is 0, must be an integer if set client_name: ...
Contributing
First of all, thank you for contributing !
Here are few rules to follow for a easier code review before the maintainers accept and merge your request.
- you MUST follow the Symfony2 coding standard : you can use
./bin/coketo validate - you MUST run the test
- you MUST write or update tests
- you MUST write or update documentation
Running the test
Install the composer dev dependencies
$ composer install --dev
Then run the test with atoum unit test framework
./bin/atoum
m6web/cassandra-bundle 适用场景与选型建议
m6web/cassandra-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 127.47k 次下载、GitHub Stars 达 30, 最近一次更新时间为 2015 年 04 月 29 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「bundle」 「cassandra」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 m6web/cassandra-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 m6web/cassandra-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 m6web/cassandra-bundle 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
The Cassandra php driver library IDE stubs which enables autocompletion in modern IDEs.
Cassandra Thrift Wrapper
2lenet/EasyAdminPlusBundle
The bundle for easy using json-rpc api on your project
Provide a way to secure accesses to all routes of an symfony application.
DMS Meetup API Bundle, enables Meetup API clients in services
统计信息
- 总下载量: 127.47k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 31
- 点击次数: 18
- 依赖项目数: 3
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-04-29