Skip to content

Commit

Permalink
Merge pull request #1 from padosoft/m-jb-test-super-cache-invalidate
Browse files Browse the repository at this point in the history
prima versione super cache invalidate
  • Loading branch information
januabisconti authored Dec 4, 2024
2 parents 4c8da35 + 0786af8 commit e10b1fb
Show file tree
Hide file tree
Showing 18 changed files with 727 additions and 641 deletions.
115 changes: 59 additions & 56 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,63 +1,66 @@
# PHP CircleCI 2.0 configuration file
# See: https://circleci.com/docs/2.0/language-php/
version: 2
version: 2.1

# Define a job to be invoked later in a workflow.
# See: https://circleci.com/docs/2.0/configuration-reference/#jobs
jobs:
build:
# Specify the execution environment. You can specify an image from Dockerhub or use one of our Convenience Images from CircleCI's Developer Hub.
# See: https://circleci.com/docs/2.0/configuration-reference/#docker-machine-macos-windows-executor
executors:
php-executor:
docker:
# Specify the version you desire here
- image: cimg/php:8.2.20-node

# Specify service dependencies here if necessary
# CircleCI maintains a library of pre-built images
# documented at https://circleci.com/docs/2.0/circleci-images/
# Using the RAM variation mitigates I/O contention
# for database intensive operations.
# - image: circleci/mysql:5.7-ram
#
#- image: redis:2.8.19
- image: cimg/php:<<parameters.php-version>>-browsers
- image: redis:alpine
parameters:
php-version:
type: string
default: "8.0"
working_directory: ~/laravel-super-cache-invalidate

# Add steps to the job
# See: https://circleci.com/docs/2.0/configuration-reference/#steps
jobs:
test:
parameters:
php-version:
type: string
laravel-version:
type: string
executor:
name: php-executor
php-version: <<parameters.php-version>>
steps:
- checkout
- run:
name: Install Redis Extension
command: |
yes 'no' | sudo pecl install -f redis || true
sudo docker-php-ext-enable redis.so
#- run:
# name: Update Composer
# command: sudo composer self-update
- run:
name: Install Dependencies
command: composer install --prefer-dist --no-interaction
- run:
name: Install Dependencies
command: |
sudo composer require "laravel/framework:^10.0" --no-update
sudo composer install --prefer-dist --no-interaction
- run:
name: Prepare bootstrap/cache directory
command: mkdir -p ./vendor/orchestra/testbench-core/laravel/bootstrap/cache && chmod -R 777 ./vendor/orchestra/testbench-core/laravel/bootstrap/cache

- 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
- run: sudo docker-php-ext-install zip
#- run: sudo install-php-extensions redis

# Download and cache dependencies
- restore_cache:
keys:
# "composer.lock" can be used if it is committed to the repo
- v1-dependencies-{{ checksum "composer.json" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-

- run: composer install -n --prefer-dist --ignore-platform-req=ext-redis

- save_cache:
key: v1-dependencies-{{ checksum "composer.json" }}
paths:
- ./vendor
#- restore_cache:
# keys:
# - node-v1-{{ checksum "package.json" }}
# - node-v1-
- run: yarn install
#- save_cache:
# key: node-v1-{{ checksum "package.json" }}
# paths:
# - node_modules

# prepare the database
#- run: touch storage/testing.sqlite
#- run: php artisan migrate --env=testing --database=sqlite_testing --force
- run:
name: Run Tests
command: |
vendor/bin/phpunit
# run tests with phpunit or codecept
#- run: ./vendor/bin/phpunit --coverage-text --coverage-clover=coverage.clover
- run: ./vendor/bin/phpunit
workflows:
version: 2
test:
jobs:
- test:
name: PHP 8.2 + Laravel 10
php-version: "8.2"
laravel-version: "10"
- test:
name: PHP 8.3 + Laravel 10
php-version: "8.3"
laravel-version: "10"
- test:
name: PHP 8.4 + Laravel 10
php-version: "8.4"
laravel-version: "10"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -468,3 +468,4 @@ resources/frontend/default/js/components/clientComponents/*

#escludo la cartella personal_scripts presente in utility così ognuno può avere i suoi script personali
utility/personal_scripts
/storage/logs/tests/.phpunit.cache/test-results
13 changes: 8 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ composer require padosoft/laravel-super-cache-invalidate
Publish the configuration and migrations:

```bash
php artisan vendor:publish --provider="Padosoft\SuperCacheInvalidate\SuperCacheInvalidationServiceProvider"
php artisan vendor:publish --provider="Padosoft\SuperCacheInvalidate\SuperCacheInvalidateServiceProvider"
```

Run migrations:
Expand All @@ -94,6 +94,7 @@ return [
'lock_timeout' => 600,
'key_invalidation_callback' => null,
'tag_invalidation_callback' => null,
'default_connection_name' => null,
];
```

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

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

// Invalidate a key
$helper->insertInvalidationEvent('key', 'cache_key_xyz', 'Specific cache key invalidated');
$helper->insertInvalidationEvent('key', 'cache_key_xyz', 'fullpage-cache', 'Specific cache key invalidated');

// Invalidate a key with associated tags
// In this example, when the event for article_ID:7 is processed,
Expand All @@ -121,10 +122,12 @@ $helper->insertInvalidationEvent('key', 'cache_key_xyz', 'Specific cache key inv
$helper->insertInvalidationEvent(
'tag',
'article_ID:7',
'fullpage-cache',
'Article 7 removed from sale',
0,
0,
[
['type' => 'tag', 'identifier' => 'plp:sport']
['type' => 'tag', 'identifier' => 'plp:sport', 'connection_name' => 'cache']
]
);
```
Expand All @@ -134,7 +137,7 @@ $helper->insertInvalidationEvent(
Schedule the processing command to run at desired intervals:

```bash
php artisan supercache:process-invalidation --shard=0 --priority=0
php artisan supercache:process-invalidation --shard=0 --priority=0 --connection_name=cache
```

You can add it to your schedule method in App\Console\Kernel.php:
Expand Down
11 changes: 5 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@
}
],
"require": {
"php" : "^8.0",
"illuminate/support": "^9.0|^10.0|^11.0" ,
"php": "^8.0",
"illuminate/support": "^9.0|^10.0|^11.0",
"laravel/framework": "^9.0|^10.0|^11.0",
"predis/predis": "^2.0",
"ext-redis": "*"
"predis/predis": "^2.0"
},
"require-dev": {
"m6web/redis-mock": "^5.6",
"phpunit/phpunit": "^9.5|^10.0|^11.0",
"orchestra/testbench": "^7.0|^8.0|^9.0",
"mockery/mockery": "^1.5",
Expand All @@ -37,8 +37,7 @@
"phpmd/phpmd": "^2.15",
"spatie/laravel-ignition": "^2.3",
"spatie/laravel-ray": "^1.32",
"squizlabs/php_codesniffer": "^3.7",
"laradumps/laradumps": "3.0"
"squizlabs/php_codesniffer": "^3.7"
},
"autoload": {
"psr-4": {
Expand Down
Loading

0 comments on commit e10b1fb

Please sign in to comment.