-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCacheStrategy.php
42 lines (35 loc) · 1.04 KB
/
CacheStrategy.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
/**
* This file is part of response-cache, a Matchory library.
*
* @author Moritz Friedrich <moritz@matchory.com>
*/
declare(strict_types=1);
namespace Matchory\ResponseCache\Contracts;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\Response;
/**
* Cache Strategy
*
* @bundle Matchory\ResponseCache
*/
interface CacheStrategy
{
/**
* Generates a unique key for a request.
*/
public function key(Request $request): string;
/**
* Determines whether the response should be cached.
*/
public function shouldCache(Request $request, Response $response): bool;
/**
* Generates a list of tags for a request. If the cache is missed, this
* method will be invoked with the generated response passed, providing an
* opportunity to add tags dependent on the generated response, for example
* the ID of a customer associated to the request, or similar.
*
* @return string[]
*/
public function tags(Request $request, Response|null $response = null): array;
}