torecan/lara-cassandra
Composer 安装命令:
composer require torecan/lara-cassandra
包简介
Cassandra based query builder for laravel.
README 文档
README
A Laraval database driver for Cassandra.
Installation
Before installation:
This is project is still on development progress, before add this on your project, please be sure minimum-stability variable is "dev"
"minimum-stability": "dev",
Install using composer:
composer require torecan/lara-cassandra
To support the Laravel database migration feature a custom migration service provider is needed:
- LaraCassandra\CassandraMigrationServiceProvider::class
It must be added at the very top of the service provider list so it can correctly override the default migration service provider.
Configuration
Change your default database connection name in config/database.php:
'default' => env('DB_CONNECTION', 'cassandra'),
And add a new cassandra connection:
'cassandra' => [
'driver' => 'cassandra',
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', 8082),
'keyspace' => env('DB_DATABASE', 'cassandra_db'),
'username' => env('DB_USERNAME', ''),
'password' => env('DB_PASSWORD', ''),
'page_size' => env('DB_PAGE_SIZE', 5000),
'consistency' => LaraCassandra\Consistency::LOCAL_ONE,
'timeout' => null,
'connect_timeout' => 5.0,
'request_timeout' => 12.0,
],
.env Examples
DB_CONNECTION=cassandra
DB_HOST=127.0.0.1
DB_PORT=8082
or
DB_CONNECTION=cassandra
DB_HOST=172.198.1.1,172.198.1.2,172.198.1.3
DB_PORT=8082,8082,7748
DB_DATABASE=db_name
DB_USERNAME=torecan
DB_PASSWORD=***
DB_PAGE_SIZE=500
Supported Consistency Settings
- LaraCassandra\Consistency::ALL
- LaraCassandra\Consistency::ANY
- LaraCassandra\Consistency::EACH_QUORUM
- LaraCassandra\Consistency::LOCAL_ONE
- LaraCassandra\Consistency::LOCAL_QUORUM
- LaraCassandra\Consistency::LOCAL_SERIAL
- LaraCassandra\Consistency::ONE
- LaraCassandra\Consistency::TWO
- LaraCassandra\Consistency::THREE
- LaraCassandra\Consistency::QUORUM
- LaraCassandra\Consistency::SERIAL
Schema
Laravel migration features are supported (when LaraCassandra\CassandraMigrationServiceProvider is used):
php artisan migrate
php artisan make:migration createNewTable
Examples
See
Not all features are supported by Cassandra - those will throw exceptions when used.
Additionaly these features are supported by this driver:
- Schemas with Partition Keys and Clustering Columns:
$table->int('bucket')->partition();
$table->int('id')->partition();
$table->int('userid')->partition();
$table->int('join_date')->clustering('DESC');
$table->int('update_date')->clustering('ASC');
$table->int('another_date')->clustering();
// Note: ->primary() is identical with partition()
-
Connection and Builder classes support setting the query consistency via
setConsistency(), for example:DB::table('example')->setConsistency(Consistency::ALL)->where('id', 1)->get(); -
Builder classes support allow filtering via
allowFiltering(), for example:DB::table('example')->where('time', '>=', 1)->allowFiltering()->get(); -
By default warnings returned by Cassandra are logged - this can be turned off if needed:
DB::table('example')->ignoreWarnings()->max('id');
Auth
! TODO !
This project is forked from https://github.com/cubettech/lacassa
torecan/lara-cassandra 适用场景与选型建议
torecan/lara-cassandra 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 40 次下载、GitHub Stars 达 1, 最近一次更新时间为 2024 年 01 月 17 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「nosql」 「database」 「query builder」 「laravel」 「cassandra」 「cql」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 torecan/lara-cassandra 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 torecan/lara-cassandra 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 torecan/lara-cassandra 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Dibi is Database Abstraction Library for PHP
The DreamFactory(tm) CouchDB Service.
Store your language lines in the database, yaml or other sources
The CodeIgniter Redis package
A package for automatically encrypting and decrypting Eloquent attributes in Laravel 5.5+, based on configuration settings.
Query filtering in your frontend
统计信息
- 总下载量: 40
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 29
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-01-17