Skip to content

Commit e10b1fb

Browse files
Merge pull request #1 from padosoft/m-jb-test-super-cache-invalidate
prima versione super cache invalidate
2 parents 4c8da35 + 0786af8 commit e10b1fb

18 files changed

+727
-641
lines changed

.circleci/config.yml

Lines changed: 59 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,66 @@
1-
# PHP CircleCI 2.0 configuration file
2-
# See: https://circleci.com/docs/2.0/language-php/
3-
version: 2
1+
version: 2.1
42

5-
# Define a job to be invoked later in a workflow.
6-
# See: https://circleci.com/docs/2.0/configuration-reference/#jobs
7-
jobs:
8-
build:
9-
# Specify the execution environment. You can specify an image from Dockerhub or use one of our Convenience Images from CircleCI's Developer Hub.
10-
# See: https://circleci.com/docs/2.0/configuration-reference/#docker-machine-macos-windows-executor
3+
executors:
4+
php-executor:
115
docker:
12-
# Specify the version you desire here
13-
- image: cimg/php:8.2.20-node
14-
15-
# Specify service dependencies here if necessary
16-
# CircleCI maintains a library of pre-built images
17-
# documented at https://circleci.com/docs/2.0/circleci-images/
18-
# Using the RAM variation mitigates I/O contention
19-
# for database intensive operations.
20-
# - image: circleci/mysql:5.7-ram
21-
#
22-
#- image: redis:2.8.19
6+
- image: cimg/php:<<parameters.php-version>>-browsers
7+
- image: redis:alpine
8+
parameters:
9+
php-version:
10+
type: string
11+
default: "8.0"
12+
working_directory: ~/laravel-super-cache-invalidate
2313

24-
# Add steps to the job
25-
# See: https://circleci.com/docs/2.0/configuration-reference/#steps
14+
jobs:
15+
test:
16+
parameters:
17+
php-version:
18+
type: string
19+
laravel-version:
20+
type: string
21+
executor:
22+
name: php-executor
23+
php-version: <<parameters.php-version>>
2624
steps:
2725
- checkout
26+
- run:
27+
name: Install Redis Extension
28+
command: |
29+
yes 'no' | sudo pecl install -f redis || true
30+
sudo docker-php-ext-enable redis.so
31+
#- run:
32+
# name: Update Composer
33+
# command: sudo composer self-update
34+
- run:
35+
name: Install Dependencies
36+
command: composer install --prefer-dist --no-interaction
37+
- run:
38+
name: Install Dependencies
39+
command: |
40+
sudo composer require "laravel/framework:^10.0" --no-update
41+
sudo composer install --prefer-dist --no-interaction
42+
- run:
43+
name: Prepare bootstrap/cache directory
44+
command: mkdir -p ./vendor/orchestra/testbench-core/laravel/bootstrap/cache && chmod -R 777 ./vendor/orchestra/testbench-core/laravel/bootstrap/cache
2845

29-
- run: sudo apt update -y && sudo apt-get install -y zip unzip # PHP CircleCI 2.0 Configuration File# PHP CircleCI 2.0 Configuration File sudo apt install zlib1g-dev libsqlite3-dev
30-
- run: sudo docker-php-ext-install zip
31-
#- run: sudo install-php-extensions redis
32-
33-
# Download and cache dependencies
34-
- restore_cache:
35-
keys:
36-
# "composer.lock" can be used if it is committed to the repo
37-
- v1-dependencies-{{ checksum "composer.json" }}
38-
# fallback to using the latest cache if no exact match is found
39-
- v1-dependencies-
40-
41-
- run: composer install -n --prefer-dist --ignore-platform-req=ext-redis
42-
43-
- save_cache:
44-
key: v1-dependencies-{{ checksum "composer.json" }}
45-
paths:
46-
- ./vendor
47-
#- restore_cache:
48-
# keys:
49-
# - node-v1-{{ checksum "package.json" }}
50-
# - node-v1-
51-
- run: yarn install
52-
#- save_cache:
53-
# key: node-v1-{{ checksum "package.json" }}
54-
# paths:
55-
# - node_modules
56-
57-
# prepare the database
58-
#- run: touch storage/testing.sqlite
59-
#- run: php artisan migrate --env=testing --database=sqlite_testing --force
46+
- run:
47+
name: Run Tests
48+
command: |
49+
vendor/bin/phpunit
6050
61-
# run tests with phpunit or codecept
62-
#- run: ./vendor/bin/phpunit --coverage-text --coverage-clover=coverage.clover
63-
- run: ./vendor/bin/phpunit
51+
workflows:
52+
version: 2
53+
test:
54+
jobs:
55+
- test:
56+
name: PHP 8.2 + Laravel 10
57+
php-version: "8.2"
58+
laravel-version: "10"
59+
- test:
60+
name: PHP 8.3 + Laravel 10
61+
php-version: "8.3"
62+
laravel-version: "10"
63+
- test:
64+
name: PHP 8.4 + Laravel 10
65+
php-version: "8.4"
66+
laravel-version: "10"

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,3 +468,4 @@ resources/frontend/default/js/components/clientComponents/*
468468

469469
#escludo la cartella personal_scripts presente in utility così ognuno può avere i suoi script personali
470470
utility/personal_scripts
471+
/storage/logs/tests/.phpunit.cache/test-results

README.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ composer require padosoft/laravel-super-cache-invalidate
7373
Publish the configuration and migrations:
7474

7575
```bash
76-
php artisan vendor:publish --provider="Padosoft\SuperCacheInvalidate\SuperCacheInvalidationServiceProvider"
76+
php artisan vendor:publish --provider="Padosoft\SuperCacheInvalidate\SuperCacheInvalidateServiceProvider"
7777
```
7878

7979
Run migrations:
@@ -94,6 +94,7 @@ return [
9494
'lock_timeout' => 600,
9595
'key_invalidation_callback' => null,
9696
'tag_invalidation_callback' => null,
97+
'default_connection_name' => null,
9798
];
9899
```
99100

@@ -108,10 +109,10 @@ use Padosoft\SuperCacheInvalidate\Helpers\SuperCacheInvalidationHelper;
108109
$helper = app(Padosoft\SuperCacheInvalidate\Helpers\SuperCacheInvalidationHelper::class);
109110

110111
// Invalidate a tag
111-
$helper->insertInvalidationEvent('tag', 'category:sport', 'Product updated in category sport');
112+
$helper->insertInvalidationEvent('tag', 'category:sport', 'cache', 'Product updated in category sport');
112113

113114
// Invalidate a key
114-
$helper->insertInvalidationEvent('key', 'cache_key_xyz', 'Specific cache key invalidated');
115+
$helper->insertInvalidationEvent('key', 'cache_key_xyz', 'fullpage-cache', 'Specific cache key invalidated');
115116

116117
// Invalidate a key with associated tags
117118
// In this example, when the event for article_ID:7 is processed,
@@ -121,10 +122,12 @@ $helper->insertInvalidationEvent('key', 'cache_key_xyz', 'Specific cache key inv
121122
$helper->insertInvalidationEvent(
122123
'tag',
123124
'article_ID:7',
125+
'fullpage-cache',
124126
'Article 7 removed from sale',
125127
0,
128+
0,
126129
[
127-
['type' => 'tag', 'identifier' => 'plp:sport']
130+
['type' => 'tag', 'identifier' => 'plp:sport', 'connection_name' => 'cache']
128131
]
129132
);
130133
```
@@ -134,7 +137,7 @@ $helper->insertInvalidationEvent(
134137
Schedule the processing command to run at desired intervals:
135138

136139
```bash
137-
php artisan supercache:process-invalidation --shard=0 --priority=0
140+
php artisan supercache:process-invalidation --shard=0 --priority=0 --connection_name=cache
138141
```
139142

140143
You can add it to your schedule method in App\Console\Kernel.php:

composer.json

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@
1919
}
2020
],
2121
"require": {
22-
"php" : "^8.0",
23-
"illuminate/support": "^9.0|^10.0|^11.0" ,
22+
"php": "^8.0",
23+
"illuminate/support": "^9.0|^10.0|^11.0",
2424
"laravel/framework": "^9.0|^10.0|^11.0",
25-
"predis/predis": "^2.0",
26-
"ext-redis": "*"
25+
"predis/predis": "^2.0"
2726
},
2827
"require-dev": {
28+
"m6web/redis-mock": "^5.6",
2929
"phpunit/phpunit": "^9.5|^10.0|^11.0",
3030
"orchestra/testbench": "^7.0|^8.0|^9.0",
3131
"mockery/mockery": "^1.5",
@@ -37,8 +37,7 @@
3737
"phpmd/phpmd": "^2.15",
3838
"spatie/laravel-ignition": "^2.3",
3939
"spatie/laravel-ray": "^1.32",
40-
"squizlabs/php_codesniffer": "^3.7",
41-
"laradumps/laradumps": "3.0"
40+
"squizlabs/php_codesniffer": "^3.7"
4241
},
4342
"autoload": {
4443
"psr-4": {

0 commit comments

Comments
 (0)