-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add cache invalidation by tag (#2)
- Loading branch information
1 parent
1b427fd
commit 0b91e27
Showing
38 changed files
with
396 additions
and
211 deletions.
There are no files selected for viewing
This file contains 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,3 @@ | ||
version: '3.7' | ||
|
||
services: | ||
web: | ||
container_name: blog.nginx | ||
|
This file contains 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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 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 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 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 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 @@ | ||
http-client.private.env.json |
This file contains 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,6 @@ | ||
# @name Cache Invalidation by tag | ||
GET {{host}}/admin/cache-invalidation?tag[]=article | ||
Content-Type: application/json | ||
Authorization: Bearer {{token}} | ||
|
||
### |
This file contains 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,12 @@ | ||
# @name Get Articles | ||
GET {{host}}/api/articles | ||
Content-Type: application/json | ||
|
||
### | ||
|
||
# @name Get Article By ID | ||
@id = 6J0hWoFCuiuWQtjp3K1mXn | ||
GET {{host}}/api/articles/{{id}} | ||
Content-Type: application/json | ||
|
||
### |
This file contains 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,107 @@ | ||
# @name Contentful Webhook : Publish BlogPage | ||
POST {{host}}/webhook/contentful/publish | ||
Content-Type: application/json | ||
Authorization: Bearer {{token}} | ||
|
||
{ | ||
"metadata": { | ||
"tags": [] | ||
}, | ||
"fields": { | ||
"title": { | ||
"fr": "Débuter avec Varnish" | ||
}, | ||
"slug": { | ||
"fr": "debuter-avec-varnish" | ||
}, | ||
"description": { | ||
"fr": "TODO" | ||
}, | ||
"content": { | ||
"fr": "TODO" | ||
}, | ||
"categories": { | ||
"fr": [] | ||
} | ||
}, | ||
"sys": { | ||
"type": "Entry", | ||
"id": "1234", | ||
"space": { | ||
"sys": { | ||
"type": "Link", | ||
"linkType": "Space", | ||
"id": "1234" | ||
} | ||
}, | ||
"environment": { | ||
"sys": { | ||
"id": "master", | ||
"type": "Link", | ||
"linkType": "Environment" | ||
} | ||
}, | ||
"contentType": { | ||
"sys": { | ||
"type": "Link", | ||
"linkType": "ContentType", | ||
"id": "blogPage" | ||
} | ||
}, | ||
"createdBy": { | ||
"sys": { | ||
"type": "Link", | ||
"linkType": "User", | ||
"id": "1234" | ||
} | ||
}, | ||
"updatedBy": { | ||
"sys": { | ||
"type": "Link", | ||
"linkType": "User", | ||
"id": "1234" | ||
} | ||
}, | ||
"revision": 3, | ||
"createdAt": "2023-12-18T19:15:54.485Z", | ||
"updatedAt": "2024-01-14T14:48:10.656Z" | ||
} | ||
} | ||
|
||
### | ||
|
||
# @name Contentful Webhook : Unpublsih BlogPage | ||
POST {{host}}/webhook/contentful/publish | ||
Content-Type: application/json | ||
|
||
{ | ||
"sys": { | ||
"type": "DeletedEntry", | ||
"id": "1234", | ||
"space": { | ||
"sys": { | ||
"type": "Link", | ||
"linkType": "Space", | ||
"id": "1234" | ||
} | ||
}, | ||
"environment": { | ||
"sys": { | ||
"id": "master", | ||
"type": "Link", | ||
"linkType": "Environment" | ||
} | ||
}, | ||
"contentType": { | ||
"sys": { | ||
"type": "Link", | ||
"linkType": "ContentType", | ||
"id": "blogPage" | ||
} | ||
}, | ||
"revision": 3, | ||
"createdAt": "2024-01-14T14:48:15.803Z", | ||
"updatedAt": "2024-01-14T14:48:15.803Z", | ||
"deletedAt": "2024-01-14T14:48:15.803Z" | ||
} | ||
} |
10 changes: 0 additions & 10 deletions
10
src/Application/Command/CacheInvalidation/CacheInvalidationCommand.php
This file was deleted.
Oops, something went wrong.
19 changes: 0 additions & 19 deletions
19
src/Application/Command/CacheInvalidation/CacheInvalidationCommandHandler.php
This file was deleted.
Oops, something went wrong.
12 changes: 12 additions & 0 deletions
12
src/Application/Command/TagCacheInvalidation/TagCacheInvalidationCommand.php
This file contains 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,12 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Application\Command\TagCacheInvalidation; | ||
|
||
final readonly class TagCacheInvalidationCommand | ||
{ | ||
public function __construct( | ||
public array $tags | ||
) {} | ||
} |
21 changes: 21 additions & 0 deletions
21
src/Application/Command/TagCacheInvalidation/TagCacheInvalidationCommandHandler.php
This file contains 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,21 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Application\Command\TagCacheInvalidation; | ||
|
||
use Symfony\Component\Messenger\Attribute\AsMessageHandler; | ||
use Symfony\Contracts\Cache\TagAwareCacheInterface; | ||
|
||
#[AsMessageHandler] | ||
final readonly class TagCacheInvalidationCommandHandler | ||
{ | ||
public function __construct( | ||
private TagAwareCacheInterface $messengerCache | ||
) {} | ||
|
||
public function __invoke(TagCacheInvalidationCommand $command): void | ||
{ | ||
$this->messengerCache->invalidateTags($command->tags); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.