-
-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathCacheInterface.php
More file actions
57 lines (49 loc) · 1.42 KB
/
CacheInterface.php
File metadata and controls
57 lines (49 loc) · 1.42 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php
declare(strict_types=1);
namespace Fetch\Cache;
/**
* Interface for cache backends used by the HTTP client.
*/
interface CacheInterface
{
/**
* Get a cached response by key.
*
* @param string $key The cache key
* @return CachedResponse|null The cached response, or null if not found
*/
public function get(string $key): ?CachedResponse;
/**
* Store a response in the cache.
*
* @param string $key The cache key
* @param CachedResponse $cachedResponse The response to cache
* @param int|null $ttl Time to live in seconds
* @return bool True if the item was stored, false otherwise
*/
public function set(string $key, CachedResponse $cachedResponse, ?int $ttl = null): bool;
/**
* Delete a cached response by key.
*
* @param string $key The cache key
* @return bool True if the item was deleted, false otherwise
*/
public function delete(string $key): bool;
/**
* Check if a key exists in the cache.
*
* @param string $key The cache key
* @return bool True if the key exists, false otherwise
*/
public function has(string $key): bool;
/**
* Clear all cached responses.
*/
public function clear(): void;
/**
* Remove expired entries from the cache.
*
* @return int The number of entries removed
*/
public function prune(): int;
}