forked from codeigniter4/CodeIgniter4
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCacheInterface.php
More file actions
106 lines (92 loc) · 2.85 KB
/
CacheInterface.php
File metadata and controls
106 lines (92 loc) · 2.85 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
<?php
declare(strict_types=1);
/**
* This file is part of CodeIgniter 4 framework.
*
* (c) CodeIgniter Foundation <admin@codeigniter.com>
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace CodeIgniter\Cache;
interface CacheInterface
{
/**
* Takes care of any handler-specific setup that must be done.
*/
public function initialize(): void;
/**
* Attempts to fetch an item from the cache store.
*
* @param string $key Cache item name
*/
public function get(string $key): mixed;
/**
* Saves an item to the cache store.
*
* @param string $key Cache item name
* @param mixed $value The data to save
* @param int $ttl Time To Live, in seconds (default 60)
*
* @return bool Success or failure
*/
public function save(string $key, $value, int $ttl = 60): bool;
/**
* Deletes a specific item from the cache store.
*
* @param string $key Cache item name
*
* @return bool Success or failure
*/
public function delete(string $key): bool;
/**
* Deletes items from the cache store matching a given pattern.
*
* @param string $pattern Cache items glob-style pattern
*
* @return int Number of deleted items
*/
public function deleteMatching(string $pattern): int;
/**
* Performs atomic incrementation of a raw stored value.
*
* @param string $key Cache ID
* @param int $offset Step/value to increase by
*/
public function increment(string $key, int $offset = 1): bool|int;
/**
* Performs atomic decrementation of a raw stored value.
*
* @param string $key Cache ID
* @param int $offset Step/value to increase by
*/
public function decrement(string $key, int $offset = 1): bool|int;
/**
* Will delete all items in the entire cache.
*
* @return bool Success or failure
*/
public function clean(): bool;
/**
* Returns information on the entire cache.
*
* The information returned and the structure of the data
* varies depending on the handler.
*
* @return array<array-key, mixed>|false|object|null
*/
public function getCacheInfo(): array|false|object|null;
/**
* Returns detailed information about the specific item in the cache.
*
* @param string $key Cache item name.
*
* @return array<string, mixed>|null Returns null if the item does not exist, otherwise array<string, mixed>
* with at least the 'expire' key for absolute epoch expiry (or null).
*/
public function getMetaData(string $key): ?array;
/**
* Determines if the driver is supported on this system.
*/
public function isSupported(): bool;
}