Skip to content

Commit

Permalink
Merge branch 'master' into lianbl/chore-remove-files
Browse files Browse the repository at this point in the history
  • Loading branch information
godruoyi authored Apr 8, 2024
2 parents dc8e4ff + ee1f3af commit def0a13
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 21 deletions.
6 changes: 0 additions & 6 deletions .github/workflows/codestyle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,6 @@ jobs:
- name: Install dependencies with composer
run: composer update --no-ansi --no-interaction --no-progress

- name: Install Laravel Illuminate Contracts
run: composer require "illuminate/contracts"

- name: Install Predis Package
run: composer require "predis/predis:^2.0"

- name: Code Style
run: vendor/bin/pint --test --config ./pint.json

Expand Down
9 changes: 5 additions & 4 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ jobs:
runs-on: ubuntu-22.04

strategy:
fail-fast: true
fail-fast: false
matrix:
php-version:
- 8.2

name: Static Analysis

Expand All @@ -30,6 +33,7 @@ jobs:
php-version: 8.2
tools: composer:v2
coverage: none
extensions: swoole, redis, pcntl

- name: Install dependencies
uses: nick-fields/retry@v2
Expand All @@ -38,8 +42,5 @@ jobs:
max_attempts: 3
command: composer update --prefer-stable --prefer-dist --no-interaction --no-progress

- name: Install Predis Package
run: composer require "predis/predis:^2.0"

- name: Execute type checking
run: vendor/bin/phpstan
6 changes: 0 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,6 @@ jobs:
- name: Install dependencies
run: composer update --prefer-stable --prefer-dist --no-interaction --no-progress

- name: Install Laravel Illuminate Contracts
run: composer require "illuminate/contracts"

- name: Install Predis Package
run: composer require "predis/predis:^2.0"

- name: PHPUnit Test
run: vendor/bin/phpunit --display-incomplete --display-skipped --display-deprecations --display-errors --display-notices --display-warnings
env:
Expand Down
7 changes: 6 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@
"require-dev": {
"phpunit/phpunit": "^10",
"laravel/pint": "^1.10",
"phpstan/phpstan": "^1.10"
"phpstan/phpstan": "^1.10",
"illuminate/contracts": "^10.0 || ^11.0",
"predis/predis": "^2.0",
"ext-redis": "*",
"ext-swoole": "*"
},
"autoload-dev": {
"psr-4": {
Expand All @@ -38,6 +42,7 @@
},
"scripts": {
"test": "vendor/bin/phpunit",
"phpstan": "vendor/bin/phpstan",
"pint": "vendor/bin/pint --config pint.json"
},
"config": {
Expand Down
6 changes: 2 additions & 4 deletions src/LaravelSequenceResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,19 @@ class LaravelSequenceResolver implements SequenceResolver
/**
* Init resolve instance, must be connected.
*/
public function __construct(protected Repository $cache) // @phpstan-ignore-line
public function __construct(protected Repository $cache)
{
}

public function sequence(int $currentTime): int
{
$key = $this->prefix.$currentTime;

// @phpstan-ignore-next-line
if ($this->cache->add($key, 1, 10)) {
return 0;
}

// @phpstan-ignore-next-line
return $this->cache->increment($key, 1);
return $this->cache->increment($key) | 0;
}

public function setCachePrefix(string $prefix): self
Expand Down

0 comments on commit def0a13

Please sign in to comment.