Download the PHP package rice/lavavel-sharding without Composer

On this page you can find all versions of the php package rice/lavavel-sharding. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package lavavel-sharding

laravel-sharding

Laravel 分表工具包 (Laravel Sharding Toolkit)

开箱即用的分表组件包,不用侵入业务代码直接使用。提供多种分片算法,满足不同业务场景的分表需求。

注意事项

小成本方案,为中小型企业进行赋能,企业有钱的话可以使用成熟的 TiDB, Apache Doris 等方案,避免 出现性能问题。本库使用 union all + 子查询的方式进行查询,避免大数据量查询(临时表大数据量性能很差)

该包还没在生产环境经受考验,要使用时可以现在测试环境跑一下,避免出现问题

功能特性

实现原理

  1. Illuminate\Database\Eloquent\Model -> Rice\LSharding\Sharding 继承 Model 类
  2. 重写 __construct, __set, getTable, forwardCallTo, newEloquentBuilder 方法
  3. 继承 Rice\LSharding\Sharding 实现对应的分表类和算法

分片算法使用教程

1. 时间分片 (DatetimeSharding)

说明:根据时间范围进行分表,适用于按时间增长的数据,如日志、订单等。

使用示例:

适用场景:日志记录、订单历史、交易记录等按时间顺序增长的数据。

2. 取模分片 (ModSharding)

说明:根据字段值进行取模运算,将数据均匀分布到多个表中。

使用示例:

适用场景:用户数据、配置信息等需要均匀分布且查询频繁的场景。

3. Hash取模分片 (HashModSharding)

说明:对字段值进行Hash计算后再取模,适合非数值类型字段的分片。

使用示例:

适用场景:商品数据、设备信息等使用字符串作为主键或标识的数据。

4. 自动时间间隔分片 (AutoIntervalSharding)

说明:根据自定义时间间隔动态调整分片,支持不同粒度的时间分片。

使用示例:

适用场景:需要灵活时间间隔的数据,如活动记录、监控数据等。

5. 边界范围分片 (BoundaryRangeSharding)

说明:根据预定义的边界范围进行分片,适合数据分布不均匀的场景。

使用示例:

适用场景:会员等级、消费金额等有明显区间特征的数据。

6. 卷积分片 (VolumeRangeSharding)

说明:按照固定数据量进行分片,每个分片存储指定数量的数据。

使用示例:

适用场景:大数据量存储,需要按固定数量分片的场景。

7. 行表达式分片 (InlineSharding)

说明:使用表达式动态计算分片,可以实现复杂的分片策略。

使用示例:

适用场景:需要复杂分片逻辑的数据,如多维度分片。

8. 复合分片 (ComplexSharding)

说明:基于多个字段进行复合分片,提供更灵活的数据分布策略。

使用示例:

适用场景:需要多维度数据分布的场景,如按地区和类型联合分片。

9. Hint分片 (HintSharding)

说明:通过外部指定分片值,灵活控制数据路由。

使用示例:

适用场景:需要手动指定分片的场景,如管理后台按日期查询。

快速上手

  1. 选择适合的分片算法
  2. 创建模型类继承相应的分片类
  3. 实现必要的抽象方法
  4. 像使用普通Eloquent模型一样使用分片模型

注意事项

  1. 在查询时尽量包含分片字段,以提高查询效率
  2. 避免跨多个分片的复杂查询,可能会影响性能
  3. 分表设计需要提前规划,考虑未来的数据增长
  4. 对于大数据量查询,建议使用更专业的分布式数据库解决方案

All versions of lavavel-sharding with dependencies

PHP Build Version
Package Version
Requires php Version >=7.4
ext-json Version *
ext-bcmath Version *
nesbot/carbon Version ^2.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package rice/lavavel-sharding contains the following files

Loading the files please wait ...