Skip to content

Commit

Permalink
feat: add ci
Browse files Browse the repository at this point in the history
  • Loading branch information
wxxiong6 committed Mar 26, 2023
1 parent 9c7fd06 commit e892a9c
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

[![Build Status](https://api.travis-ci.org/wxxiong6/php-ext-snowflake.svg?branch=master)](https://travis-ci.org/wxxiong6/php-ext-snowflake) [![Build status](https://ci.appveyor.com/api/projects/status/awii6wf2ocmy202p/branch/master?svg=true)](https://ci.appveyor.com/project/wxxiong6/php-ext-snowflake/branch/master)


扩展使用Snowflake算法实现分布式唯一ID生成器的PHP扩展。它可以生成全局唯一且有序的ID。

PHP多进程环境下确保ID唯一性的确是一个挑战,因为多个进程可能同时尝试生成ID,这可能导致ID重复。在网上看到很多php扩展实现的snowflake都没有解决多进程id重复的问题, 本扩展使用自旋锁确保唯一它可以避免多个进程同时生成ID的情况。
Expand All @@ -11,7 +12,6 @@ PHP多进程环境下确保ID唯一性的确是一个挑战,因为多个进程
总的来说,使用Snowflake算法实现分布式唯一ID生成器的PHP扩展是一个不错的选择,特别是对于需要在高并发环境下生成ID的应用程序来说。但是请确保正确地配置和使用扩展,并测试其在您的环境中的性能和可靠性。



- 基于[Twitter SnowFlake](https://github.com/twitter-archive/snowflake "Twitter SnowFlake")分布式ID生成算法,使用c实现的php Extension。
- 默认生成ID是一个64位long型数字。
- 单机每秒内理论上最多可以生成1024*(2^12),也就是409.6万个ID(1024 X 4096 = 4194304)。
Expand Down
51 changes: 51 additions & 0 deletions integrate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: integrate
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
matrix:
name: "PHP"
runs-on: ubuntu-20.04
strategy:
matrix:
PHP: ["7.0", "7.1", "7.2", "7.3", "7.4", "8.0", "8.1"]
ZTS: ["no"]
include:
- PHP: "8.1"
OS: "ubuntu-latest"
ZTS: true
env:
PHP: ${{ matrix.PHP }}
GITHUB: "yes"
enable_debug: "yes"
enable_session: "yes"
enable_maintainer_zts: ${{ matrix.ZTS }}
TEST_PHP_ARGS : "--show-diff"
REPORT_EXIT_STATUS: "yes"
NO_INTERACTION: "yes"
steps:
- name: Checkout
uses: actions/checkout@v2
with:
submodules: true
- name: Setup
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.PHP }}
- name: Install
run: |
sudo apt-get install -y re2c
- name: Prepare
run: |
phpize
- name: Build
run: |
./configure
- name: Make
run: |
make
- name: Test
run: |
make test

0 comments on commit e892a9c

Please sign in to comment.