-
Notifications
You must be signed in to change notification settings - Fork 4
/
CacheSelector.php
107 lines (95 loc) · 2.74 KB
/
CacheSelector.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
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
107
<?php
/**
* Interface CacheSelector
*
* @package LeavesAndLove\WpPsrCache
* @license GNU General Public License, version 2
* @link https://github.com/felixarntz/wp-psr-cache
*/
namespace LeavesAndLove\WpPsrCache\CacheSelector;
use LeavesAndLove\WpPsrCache\CacheAdapter\CacheAdapter;
/**
* Cache selector interface.
*
* @since 1.0.0
*/
interface CacheSelector
{
/**
* Registers a cache adapter for a set of persistent groups.
*
* @since 1.0.0
*
* @param CacheAdapter $cache Cache adapter.
* @param array $groups List of groups to use the cache adapter for.
*/
public function registerPersistentCache(CacheAdapter $cache, array $groups);
/**
* Registers a cache adapter for a set of non-persistent groups.
*
* @since 1.0.0
*
* @param CacheAdapter $cache Cache adapter.
* @param array $groups List of groups to use the cache adapter for.
*/
public function registerNonPersistentCache(CacheAdapter $cache, array $groups);
/**
* Selects the persistent cache adapter to use for a given cache group.
*
* @since 1.0.0
*
* @param string $group A cache group.
* @return CacheAdapter Cache adapter to use for the group.
*/
public function selectPersistentCache(string $group): CacheAdapter;
/**
* Selects the non-persistent cache adapter to use for a given cache group.
*
* @since 1.0.0
*
* @param string $group A cache group.
* @return CacheAdapter Cache adapter to use for the group.
*/
public function selectNonPersistentCache(string $group): CacheAdapter;
/**
* Add cache groups to consider non-persistent groups.
*
* @since 1.0.0
*
* @param array $groups The list of groups that are non-persistent.
*/
public function addNonPersistentGroups(array $groups);
/**
* Gets the list of non-persistent groups.
*
* @since 1.0.0
*
* @return array List of non-persistent groups.
*/
public function getNonPersistentGroups(): array;
/**
* Determine whether a cache group is non-persistent.
*
* @since 1.0.0
*
* @param string $group A cache group.
* @return bool True if the group is non-persistent, false otherwise.
*/
public function isNonPersistentGroup(string $group): bool;
/**
* Delete all values from the persistent caches.
*
* @since 1.0.0
*
* @return bool True on success, false on failure.
*/
public function clearPersistent(): bool;
/**
* Delete all values from the non-persistent caches.
*
* @since 1.0.0
*
* @return bool True on success, false on failure.
*/
public function clearNonPersistent(): bool;
}