Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
276e68d
Add Redis MultiExec trait
binaryfire Dec 12, 2025
fbe8634
Add new helpers to RedisConnection and update docblock
binaryfire Dec 12, 2025
4f0d09e
Add Redis package tests
binaryfire Dec 12, 2025
f4e28a3
Add Redis package tests
binaryfire Dec 12, 2025
baedd33
Add Redis package tests
binaryfire Dec 12, 2025
381cf77
Update Redis facade docblock with new methods
binaryfire Dec 12, 2025
3fa92da
Redis driver: flush by pattern
binaryfire Dec 12, 2025
3642f9a
Redis driver: non-tagged operations classes
binaryfire Dec 12, 2025
e2c5a7d
Redis driver: 'all' tag mode operations classes
binaryfire Dec 12, 2025
f91ea3e
Redis driver: 'any' tag mode operations classes
binaryfire Dec 12, 2025
35c7720
Redis driver: SafeScan for prefix-friendly performing scans
binaryfire Dec 12, 2025
9e8b1ff
Redis driver: fix directory structure
binaryfire Dec 12, 2025
7d0b5a1
Redis driver: separate tagged cache + tag set classes per tag mode
binaryfire Dec 12, 2025
4f2a4b2
Redis driver: TagMode enum
binaryfire Dec 12, 2025
1fb663d
Redis driver: prune stale tags command for cleanup in both tag modes
binaryfire Dec 12, 2025
8f5c5b4
Redis driver: prune stale tags command for cleanup in both tag modes
binaryfire Dec 12, 2025
6fff416
Redis driver: benchmark command
binaryfire Dec 12, 2025
a3b2851
Redis driver: benchmark command
binaryfire Dec 12, 2025
461077a
Redis driver: store detection trait for commands
binaryfire Dec 12, 2025
8212419
Redis driver: doctor command for friendly debugging of issues
binaryfire Dec 12, 2025
cc696ce
Redis driver: doctor command for friendly debugging of issues
binaryfire Dec 12, 2025
af234aa
Redis driver: serialization and store context support classes
binaryfire Dec 12, 2025
bd28db9
Redis driver: inline lock Lua script and delete LuaScripts to keep st…
binaryfire Dec 12, 2025
691036e
Add .tmp dir for storage of temporary files during development
binaryfire Dec 12, 2025
ff1849e
Redis driver: merge new components package changes
binaryfire Dec 12, 2025
e517a34
Redis driver: merge new components package changes
binaryfire Dec 12, 2025
08b2a30
Redis driver: merge new components package changes
binaryfire Dec 12, 2025
f93d065
Redis driver: merge new components package changes
binaryfire Dec 12, 2025
7d7d7fd
Redis driver: merge new components package changes
binaryfire Dec 12, 2025
c09f40f
Redis driver: add monitoring and system info support classes
binaryfire Dec 12, 2025
97dbb67
Redis driver: merge new driver tests
binaryfire Dec 12, 2025
0a362c2
Redis driver: merge new driver tests
binaryfire Dec 12, 2025
88ff8d4
Redis driver: merge new driver tests
binaryfire Dec 12, 2025
dbced16
Redis driver: merge new driver tests
binaryfire Dec 12, 2025
b4472e8
Redis driver: add exception classes
binaryfire Dec 12, 2025
f272e80
Remove unnecessary client method from RedisConnection
binaryfire Dec 12, 2025
f61dd5c
Redis driver: fix phpstan errors
binaryfire Dec 12, 2025
bfa3cc0
Redis driver: fix phpstan errors
binaryfire Dec 12, 2025
adca807
Redis driver: fix phpstan errors
binaryfire Dec 12, 2025
6aa9b14
Redis driver: fix phpstan errors
binaryfire Dec 12, 2025
98f7984
Add .env support for tests and set up for integration tests
binaryfire Dec 12, 2025
e0d0df8
Redis integration testing
binaryfire Dec 12, 2025
d49d38a
Redis integration testing
binaryfire Dec 12, 2025
989b1ad
Fix code style and phpstan
binaryfire Dec 12, 2025
833e06c
Switch Redis integration tests to Swoole 6.1.4 image for PhpRedis 6.3.0
binaryfire Dec 12, 2025
e14de46
Fix tests
binaryfire Dec 12, 2025
cbe5452
Fix composer class name warnings, add package caching to CI
binaryfire Dec 12, 2025
ac8d3ff
Redis cache: integration tests wip
binaryfire Dec 12, 2025
af5b175
Redis cache: integration tests wip
binaryfire Dec 12, 2025
67bfbbc
Redis cache: integration tests wip
binaryfire Dec 12, 2025
cee5ae6
Redis cache: integration tests wip
binaryfire Dec 12, 2025
5d41d1d
Redis cache: integration tests wip
binaryfire Dec 12, 2025
1b1fd4d
Redis cache: integration tests wip
binaryfire Dec 12, 2025
e9140bc
Redis cache: integration tests wip
binaryfire Dec 12, 2025
5e761b5
Redis cache: integration tests wip
binaryfire Dec 12, 2025
b300ce4
Redis cache: integration tests wip
binaryfire Dec 12, 2025
2f4a1ef
Redis cache: tests
binaryfire Dec 12, 2025
1034aad
Fix phpstan and code style
binaryfire Dec 12, 2025
4ff4e57
Paratest for integration tests wip
binaryfire Dec 12, 2025
959544f
Redis cache: reorganise support classes
binaryfire Dec 13, 2025
985d94c
Redis cache: update config file
binaryfire Dec 13, 2025
04bf635
Update prune tags command signature
binaryfire Dec 13, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Redis Integration Tests
# Copy this file to .env and configure to run integration tests locally.
# These tests are skipped by default. Set RUN_REDIS_INTEGRATION_TESTS=true to enable.

# Enable/disable Redis integration tests
RUN_REDIS_INTEGRATION_TESTS=false

# Redis connection settings
# Defaults work for standard local Redis (localhost:6379, no auth, DB 8)
REDIS_HOST=127.0.0.1
REDIS_PORT=6379
REDIS_AUTH=
REDIS_DB=8
62 changes: 61 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,71 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4

- name: Cache Composer dependencies
uses: actions/cache@v4
with:
path: /root/.composer/cache
key: composer-${{ matrix.php }}-${{ hashFiles('composer.lock') }}
restore-keys: composer-${{ matrix.php }}-

- name: Install dependencies
run: |
COMPOSER_MEMORY_LIMIT=-1 composer install --prefer-dist -n -o

- name: Execute tests
run: |
PHP_CS_FIXER_IGNORE_ENV=1 vendor/bin/php-cs-fixer fix --dry-run --diff
vendor/bin/phpunit -c phpunit.xml.dist
vendor/bin/phpunit -c phpunit.xml.dist --exclude-group redis-integration

redis_integration_tests:
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, '[skip ci]') && !contains(github.event.head_commit.message, '[ci skip]')"

strategy:
fail-fast: false
matrix:
include:
- redis: "redis:8"
name: "Redis 8"
- redis: "valkey/valkey:9"
name: "Valkey 9"

name: Integration (${{ matrix.name }})

services:
redis:
image: ${{ matrix.redis }}
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 6379:6379

container:
image: phpswoole/swoole:6.1.4-php8.4

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:
RUN_REDIS_INTEGRATION_TESTS: true
REDIS_HOST: redis
REDIS_PORT: 6379
REDIS_DB: 8
run: |
vendor/bin/phpunit -c phpunit.xml.dist --group redis-integration
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
.idea
/.env
/.phpunit.cache
/.tmp
/vendor
composer.lock
/phpunit.xml
Expand Down
1 change: 1 addition & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
bootstrap="tests/bootstrap.php"
beStrictAboutTestsThatDoNotTestAnything="false"
colors="true"
processIsolation="false"
Expand Down
1 change: 1 addition & 0 deletions src/cache/publish/cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
'redis' => [
'driver' => 'redis',
'connection' => 'default',
'tag_mode' => env('REDIS_CACHE_TAG_MODE', 'all'), // Redis 8.0+ and PhpRedis 6.3.0+ required for 'any'
'lock_connection' => 'default',
],

Expand Down
1 change: 1 addition & 0 deletions src/cache/src/CacheManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ protected function createRedisDriver(array $config): Repository
$connection = $config['connection'] ?? 'default';

$store = new RedisStore($redis, $this->getPrefix($config), $connection);
$store->setTagMode($config['tag_mode'] ?? 'all');

return $this->repository(
$store->setLockConnection($config['lock_connection'] ?? $connection),
Expand Down
6 changes: 6 additions & 0 deletions src/cache/src/ConfigProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
use Hypervel\Cache\Contracts\Store;
use Hypervel\Cache\Listeners\CreateSwooleTable;
use Hypervel\Cache\Listeners\CreateTimer;
use Hypervel\Cache\Redis\Console\BenchmarkCommand;
use Hypervel\Cache\Redis\Console\DoctorCommand;
use Hypervel\Cache\Redis\Console\PruneStaleTagsCommand;

class ConfigProvider
{
Expand All @@ -25,8 +28,11 @@ public function __invoke(): array
CreateTimer::class,
],
'commands' => [
BenchmarkCommand::class,
ClearCommand::class,
DoctorCommand::class,
PruneDbExpiredCommand::class,
PruneStaleTagsCommand::class,
],
'publish' => [
[
Expand Down
27 changes: 0 additions & 27 deletions src/cache/src/LuaScripts.php

This file was deleted.

76 changes: 76 additions & 0 deletions src/cache/src/Redis/AllTagSet.php
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);
}
}
Loading