-
-
Notifications
You must be signed in to change notification settings - Fork 15
Complete Redis cache driver refactor with enhanced tagging #289
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
binaryfire
wants to merge
156
commits into
hypervel:0.4
Choose a base branch
from
binaryfire:redis-cache-driver
base: 0.4
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
156 commits
Select commit
Hold shift + click to select a range
276e68d
Add Redis MultiExec trait
binaryfire fbe8634
Add new helpers to RedisConnection and update docblock
binaryfire 4f0d09e
Add Redis package tests
binaryfire f4e28a3
Add Redis package tests
binaryfire baedd33
Add Redis package tests
binaryfire 381cf77
Update Redis facade docblock with new methods
binaryfire 3fa92da
Redis driver: flush by pattern
binaryfire 3642f9a
Redis driver: non-tagged operations classes
binaryfire e2c5a7d
Redis driver: 'all' tag mode operations classes
binaryfire f91ea3e
Redis driver: 'any' tag mode operations classes
binaryfire 35c7720
Redis driver: SafeScan for prefix-friendly performing scans
binaryfire 9e8b1ff
Redis driver: fix directory structure
binaryfire 7d0b5a1
Redis driver: separate tagged cache + tag set classes per tag mode
binaryfire 4f2a4b2
Redis driver: TagMode enum
binaryfire 1fb663d
Redis driver: prune stale tags command for cleanup in both tag modes
binaryfire 8f5c5b4
Redis driver: prune stale tags command for cleanup in both tag modes
binaryfire 6fff416
Redis driver: benchmark command
binaryfire a3b2851
Redis driver: benchmark command
binaryfire 461077a
Redis driver: store detection trait for commands
binaryfire 8212419
Redis driver: doctor command for friendly debugging of issues
binaryfire cc696ce
Redis driver: doctor command for friendly debugging of issues
binaryfire af234aa
Redis driver: serialization and store context support classes
binaryfire bd28db9
Redis driver: inline lock Lua script and delete LuaScripts to keep st…
binaryfire 691036e
Add .tmp dir for storage of temporary files during development
binaryfire ff1849e
Redis driver: merge new components package changes
binaryfire e517a34
Redis driver: merge new components package changes
binaryfire 08b2a30
Redis driver: merge new components package changes
binaryfire f93d065
Redis driver: merge new components package changes
binaryfire 7d7d7fd
Redis driver: merge new components package changes
binaryfire c09f40f
Redis driver: add monitoring and system info support classes
binaryfire 97dbb67
Redis driver: merge new driver tests
binaryfire 0a362c2
Redis driver: merge new driver tests
binaryfire 88ff8d4
Redis driver: merge new driver tests
binaryfire dbced16
Redis driver: merge new driver tests
binaryfire b4472e8
Redis driver: add exception classes
binaryfire f272e80
Remove unnecessary client method from RedisConnection
binaryfire f61dd5c
Redis driver: fix phpstan errors
binaryfire bfa3cc0
Redis driver: fix phpstan errors
binaryfire adca807
Redis driver: fix phpstan errors
binaryfire 6aa9b14
Redis driver: fix phpstan errors
binaryfire 98f7984
Add .env support for tests and set up for integration tests
binaryfire e0d0df8
Redis integration testing
binaryfire d49d38a
Redis integration testing
binaryfire 989b1ad
Fix code style and phpstan
binaryfire 833e06c
Switch Redis integration tests to Swoole 6.1.4 image for PhpRedis 6.3.0
binaryfire e14de46
Fix tests
binaryfire cbe5452
Fix composer class name warnings, add package caching to CI
binaryfire ac8d3ff
Redis cache: integration tests wip
binaryfire af5b175
Redis cache: integration tests wip
binaryfire 67bfbbc
Redis cache: integration tests wip
binaryfire cee5ae6
Redis cache: integration tests wip
binaryfire 5d41d1d
Redis cache: integration tests wip
binaryfire 1b1fd4d
Redis cache: integration tests wip
binaryfire e9140bc
Redis cache: integration tests wip
binaryfire 5e761b5
Redis cache: integration tests wip
binaryfire b300ce4
Redis cache: integration tests wip
binaryfire 2f4a1ef
Redis cache: tests
binaryfire 1034aad
Fix phpstan and code style
binaryfire 4ff4e57
Paratest for integration tests wip
binaryfire 959544f
Redis cache: reorganise support classes
binaryfire 985d94c
Redis cache: update config file
binaryfire 04bf635
Update prune tags command signature
binaryfire 374db66
Merge remote-tracking branch 'origin/main' into redis-cache-driver
binaryfire 6fba10f
Merge remote-tracking branch 'origin/main' into redis-cache-driver
binaryfire ce31548
Fix PHPStan level 5 errors in cache package
binaryfire ecc1f8d
Add phpstan-ignore for known Redis exception bug
binaryfire 4f5e1c1
Fix GetTaggedKeys HSCAN iterator initialization
binaryfire 771060a
Add CollectedBy attribute
binaryfire 96eb890
Add @group integration to all integration tests for unified exclusion
binaryfire 7d4fadd
Merge remote-tracking branch 'origin/main' into feature/collected-by-…
binaryfire 9059ed7
Add $collectionClass property support for custom collections
binaryfire 61b4a91
Add HasCollection support to Pivot and MorphPivot
binaryfire fa87a70
Merge branch 'main' into redis-cache-driver
binaryfire 5134da7
Restore LuaScripts class and revert RedisLock to use it
binaryfire 9ec5ac8
Extract Lua scripts to dedicated methods with ARGV documentation
binaryfire de49cfd
Update .env example
binaryfire 16b886b
chore: add types analysis to CI workflow
storyn26383 c797914
feat(testing): add testbench-style testing infrastructure (phases 1-4.2)
binaryfire 7e42a9f
feat(testing): add InteractsWithTestCase trait
binaryfire 9edebb2
feat(testing): add TestingFeature orchestrator
binaryfire 5a41b4b
feat(testing): add testing attributes
binaryfire fbd99ee
feat(testbench): add package provider, route, and database traits
binaryfire c0b27a5
feat(testbench): integrate traits and attributes into TestCase
binaryfire 7442f0a
test(foundation): add AttributesTest for testing attributes
binaryfire d1bd785
test(foundation): add HandlesAttributesTest
binaryfire 87b8d6d
test(foundation): add InteractsWithTestCaseTest
binaryfire 89be1bb
test(testbench): add CreatesApplicationTest
binaryfire 8c975e5
test(testbench): add HandlesRoutesTest
binaryfire 682f152
test(testbench): add TestCaseTest
binaryfire 9163bb8
fix(testing): fix return types and attribute execution in testing inf…
binaryfire 406d743
style: apply php-cs-fixer formatting
binaryfire 9d96389
feat(testbench): integrate route registration into TestCase lifecycle
binaryfire 15c8dfd
style: apply php-cs-fixer formatting to testbench routes
binaryfire e91a8da
test(testing): add tests for Define meta-attribute and attribute inhe…
binaryfire 78f73d3
refactor(testing): add ApplicationContract and Router type hints
binaryfire ff59427
Add withConnection() method for coroutine-safe pinned connections
binaryfire e9779ba
Refactor flushByPattern() to use withConnection()
binaryfire f4d789a
Add transform parameter to Redis::withConnection() for raw phpredis s…
binaryfire eeebf22
Consolidate Redis cache test infrastructure into RedisCacheTestCase
binaryfire 21bf5a0
Add evalWithShaCache method to RedisConnection for robust Lua script …
binaryfire 9cb1f75
Clear stale errors before evalSha in evalWithShaCache
binaryfire c8b7ec1
Remove unnecessary client() indirection from Redis operations
binaryfire b6663c2
Fix RedisConnection @method annotations
binaryfire 35d380f
Add missing Laravel validation rules: Contains, DoesntContain, dateTime
binaryfire d27ef93
Merge remote-tracking branch 'origin/main' into redis-cache-driver
binaryfire 6447eb1
Merge pull request #343 from hypervel/feature/workflows
albertcht 2ea79d8
Merge branch 'main' into feature/collected-by-attribute
albertcht eb92fac
chore: fix phpstan errors
albertcht 9d5eb09
chore: remove redundant phpdocs
albertcht 64018e8
Merge pull request #345 from binaryfire/port-missing-validation-rules
albertcht 6927f45
Merge pull request #331 from binaryfire/feature/collected-by-attribute
albertcht 7861a6e
chore: fix phpstan errors
bluehaha 39aa2fe
Merge pull request #350 from bluehaha/feature/fix-phpstan
albertcht d3320f8
Merge branch 'main' into redis-cache-driver
binaryfire 835a5ba
refactor: rename $ctx to $context in benchmark and doctor commands
binaryfire 7459371
Merge branch 'main' into feat/testbench-testing-features
binaryfire 8d6fafb
fix: address PR review feedback for testing attributes
binaryfire e1c086f
chore: remove unused TestingFeature class
binaryfire 8490d83
chore: avoid using abbreviated variables
albertcht 05e2f16
Merge branch 'redis-cache-driver' of github.com:binaryfire/hypervel-c…
albertcht 25e27eb
Merge pull request #344 from binaryfire/feat/testbench-testing-features
albertcht 59b9a9d
Merge remote-tracking branch 'origin/main' into redis-cache-driver
binaryfire 7f69ce1
refactor: simplify enum_value() helper function
binaryfire f3ffec6
feat: add UnitEnum support to Collection
binaryfire d90fe65
feat: add countBy with UnitEnum support to LazyCollection
binaryfire 90c4d63
feat: add UnitEnum support to Js class
binaryfire 680ef0e
feat: add UnitEnum support for timezone in InteractsWithData::date()
binaryfire 0c0c58f
feat: add UnitEnum support to Facades
binaryfire fbe8b9a
feat: add UnitEnum support to session package
binaryfire 393cfb8
feat(cache): add UnitEnum support to cache package
binaryfire 3596d98
feat(cache): add UnitEnum support to Redis tagged cache
binaryfire bbe13b4
feat(core): add UnitEnum support to Context class
binaryfire 71f1d60
feat(core): add UnitEnum support to Eloquent components
binaryfire 4d183ef
feat(core): add UnitEnum support to Query Builder
binaryfire 13d2202
feat: add UnitEnum support to auth, broadcasting, and bus packages
binaryfire 104f43b
feat: add UnitEnum support to console and cookie packages
binaryfire 9248a9f
feat: add UnitEnum support to event and filesystem packages
binaryfire 6e3f1f3
feat(foundation): add UnitEnum support
binaryfire cc99244
refactor(permission): simplify type hints to UnitEnum
binaryfire c49a82a
refactor(queue): simplify RateLimited type hint to UnitEnum
binaryfire 9059da3
feat(redis): add UnitEnum support to connection() method
binaryfire 954a7e2
test: add enum support test files from 0.4 branch
binaryfire 9c42e09
feat: add UnitEnum support to router, sanctum, and translation packages
binaryfire 943ec65
feat: add UnitEnum support to validation and horizon packages
binaryfire 1b266bc
revert: keep original ProcessInspector docblock annotation
binaryfire 5681f9c
fix: add phpstan-ignore for HasCollection generic type errors
binaryfire a7f1b26
fix: use artisan instead of bin/hyperf.php in benchmark command messages
binaryfire 4c4e612
feat: add Prohibitable trait to benchmark and doctor commands
binaryfire 45e12bd
Merge branch '0.4' (enum support manually ported)
binaryfire f5f2889
feat: add InteractsWithRedis trait with auto-skip for Redis integrati…
binaryfire 291f788
fix: use swoole 6.1.4 container for Redis integration tests
binaryfire e56ddaa
Update .env example
binaryfire 05fe0f7
fix: update redis workflow and cache config
binaryfire 71bb490
feat: add Redis/MySQL services to tests.yml and auto-skip any-mode tests
binaryfire 38f7c09
fix: add MySQL config and improve any tag mode skip caching
binaryfire afa6b59
revert: remove Redis/MySQL services from tests.yml for now
binaryfire File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| # Integration tests environment example | ||
| # Copy this file to .env and configure to run integration tests locally. | ||
| # | ||
| # ## Database Configuration## | ||
| # Set DB_CONNECTION to the database you want to test against. | ||
| # Tests in tests/Integration/Database will run against this connection. | ||
| # | ||
| # ## Redis Configuration ## | ||
| # Integration tests auto-skip if Redis is unavailable on default host/port. | ||
| # Set REDIS_HOST to run tests against a specific Redis instance. | ||
| # If REDIS_HOST is set explicitly, tests will fail (not skip) if Redis is unavailable. | ||
|
|
||
| # Database | ||
| # DB_CONNECTION=mysql | ||
| # DB_HOST=127.0.0.1 | ||
| # DB_PORT=3306 | ||
| # DB_DATABASE=testing | ||
| # DB_USERNAME=root | ||
| # DB_PASSWORD=password | ||
|
|
||
| # Redis | ||
| # REDIS_HOST=127.0.0.1 | ||
| # REDIS_PORT=6379 | ||
| # REDIS_AUTH= | ||
| # REDIS_DB=8 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,98 @@ | ||
| name: redis | ||
|
|
||
| on: | ||
| push: | ||
| pull_request: | ||
|
|
||
| jobs: | ||
| redis_8: | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 10 | ||
|
|
||
| services: | ||
| redis: | ||
| image: redis:8 | ||
| ports: | ||
| - 6379:6379 | ||
| options: >- | ||
| --health-cmd "redis-cli ping" | ||
| --health-interval 10s | ||
| --health-timeout 5s | ||
| --health-retries 5 | ||
|
|
||
| container: | ||
| image: phpswoole/swoole:6.1.4-php8.4 | ||
|
|
||
| strategy: | ||
| fail-fast: true | ||
|
|
||
| name: Redis 8 | ||
|
|
||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Cache Composer dependencies | ||
| uses: actions/cache@v4 | ||
| with: | ||
| path: /root/.composer/cache | ||
| key: composer-8.4-${{ hashFiles('composer.lock') }} | ||
| restore-keys: composer-8.4- | ||
|
|
||
| - name: Install dependencies | ||
| run: COMPOSER_MEMORY_LIMIT=-1 composer install --prefer-dist -n -o | ||
|
|
||
| - name: Execute Redis integration tests | ||
| env: | ||
| REDIS_HOST: redis | ||
| REDIS_PORT: 6379 | ||
| REDIS_DB: 8 | ||
| run: | | ||
| vendor/bin/phpunit tests/Integration/Cache/Redis | ||
| vendor/bin/phpunit tests/Redis/Integration | ||
|
|
||
| valkey_9: | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 10 | ||
|
|
||
| services: | ||
| valkey: | ||
| image: valkey/valkey:9 | ||
| ports: | ||
| - 6379:6379 | ||
| options: >- | ||
| --health-cmd "valkey-cli ping" | ||
| --health-interval 10s | ||
| --health-timeout 5s | ||
| --health-retries 5 | ||
|
|
||
| container: | ||
| image: phpswoole/swoole:6.1.4-php8.4 | ||
|
|
||
| strategy: | ||
| fail-fast: true | ||
|
|
||
| name: Valkey 9 | ||
|
|
||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Cache Composer dependencies | ||
| uses: actions/cache@v4 | ||
| with: | ||
| path: /root/.composer/cache | ||
| key: composer-8.4-${{ hashFiles('composer.lock') }} | ||
| restore-keys: composer-8.4- | ||
|
|
||
| - name: Install dependencies | ||
| run: COMPOSER_MEMORY_LIMIT=-1 composer install --prefer-dist -n -o | ||
|
|
||
| - name: Execute Redis integration tests | ||
| env: | ||
| REDIS_HOST: valkey | ||
| REDIS_PORT: 6379 | ||
| REDIS_DB: 8 | ||
| run: | | ||
| vendor/bin/phpunit tests/Integration/Cache/Redis | ||
| vendor/bin/phpunit tests/Redis/Integration |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,7 @@ | ||
| .idea | ||
| /.env | ||
| /.phpunit.cache | ||
| /.tmp | ||
| /vendor | ||
| composer.lock | ||
| /phpunit.xml | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Hypervel\Cache\Redis; | ||
|
|
||
| use Hyperf\Collection\LazyCollection; | ||
| use Hypervel\Cache\Contracts\Store; | ||
| use Hypervel\Cache\RedisStore; | ||
| use Hypervel\Cache\TagSet; | ||
|
|
||
| class AllTagSet extends TagSet | ||
| { | ||
| /** | ||
| * The cache store implementation. | ||
| * | ||
| * @var RedisStore | ||
| */ | ||
| protected Store $store; | ||
|
|
||
| /** | ||
| * Add a reference entry to the tag set's underlying sorted set. | ||
| */ | ||
| public function addEntry(string $key, int $ttl = 0, ?string $updateWhen = null): void | ||
| { | ||
| $this->store->allTagOps()->addEntry()->execute($key, $ttl, $this->tagIds(), $updateWhen); | ||
| } | ||
|
|
||
| /** | ||
| * Get all of the cache entry keys for the tag set. | ||
| */ | ||
| public function entries(): LazyCollection | ||
| { | ||
| return $this->store->allTagOps()->getEntries()->execute($this->tagIds()); | ||
| } | ||
|
|
||
| /** | ||
| * Flush the tag from the cache. | ||
| */ | ||
| public function flushTag(string $name): string | ||
| { | ||
| return $this->resetTag($name); | ||
| } | ||
|
|
||
| /** | ||
| * Reset the tag and return the new tag identifier. | ||
| */ | ||
| public function resetTag(string $name): string | ||
| { | ||
| $this->store->forget($this->tagKey($name)); | ||
|
|
||
| return $this->tagId($name); | ||
| } | ||
|
|
||
| /** | ||
| * Get the unique tag identifier for a given tag. | ||
| * | ||
| * Delegates to StoreContext which delegates to TagMode (single source of truth). | ||
| * Format: "_all:tag:{name}:entries" | ||
| */ | ||
| public function tagId(string $name): string | ||
| { | ||
| return $this->store->getContext()->tagId($name); | ||
| } | ||
|
|
||
| /** | ||
| * Get the tag identifier key for a given tag. | ||
| * | ||
| * Same as tagId() - the identifier without cache prefix. | ||
| * Used with store->forget() which adds the prefix. | ||
| */ | ||
| public function tagKey(string $name): string | ||
| { | ||
| return $this->store->getContext()->tagId($name); | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @binaryfire , should we avoid requiring this command in production environment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@albertcht In the Laravel version I used Prohibitable and left it up to the user. I think that might be better, because advanced users may want to benchmark production setups from time to time. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I think adding
Prohibitabletrait is better. It can prevent users executing this command unexpectedly.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@binaryfire , I think we can also add
Prohibitableto the doctor command?Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@albertcht Sure, I'll do it. The doctor command is lightweight and uses prefixed keys to avoid collisions. It's designed for detecting issues in production. But there's no harm in having
Prohibitableon it as well. Then users can decide.