1 | <?php |
||
13 | class CacheConfig extends AbstractConfig |
||
14 | { |
||
15 | /** |
||
16 | * Human-readable intervals in seconds. |
||
17 | */ |
||
18 | const HOUR_IN_SECONDS = 3600; |
||
19 | const DAY_IN_SECONDS = 86400; |
||
20 | const WEEK_IN_SECONDS = 604800; |
||
21 | |||
22 | /** |
||
23 | * Cache driver(s). |
||
24 | * |
||
25 | * @var array |
||
26 | */ |
||
27 | private $types = [ 'memory' ]; |
||
28 | |||
29 | /** |
||
30 | * Time-to-live in seconds. |
||
31 | * |
||
32 | * @var integer |
||
33 | */ |
||
34 | private $defaultTtl = self::WEEK_IN_SECONDS; |
||
35 | |||
36 | /** |
||
37 | * Cache namespace. |
||
38 | * |
||
39 | * @var string |
||
40 | */ |
||
41 | private $prefix = 'charcoal'; |
||
42 | |||
43 | /** |
||
44 | * @return array |
||
45 | */ |
||
46 | public function defaults() |
||
54 | |||
55 | /** |
||
56 | * Set the types (drivers) of cache. |
||
57 | * |
||
58 | * The first cache actually available on the system will be the one used for caching. |
||
59 | * |
||
60 | * @param string[] $types The types of cache to try using, in order of priority. |
||
61 | * @return CacheConfig Chainable |
||
62 | */ |
||
63 | public function setTypes(array $types) |
||
71 | |||
72 | /** |
||
73 | * Get the valid types (drivers). |
||
74 | * |
||
75 | * @return array |
||
76 | */ |
||
77 | public function validTypes() |
||
89 | |||
90 | /** |
||
91 | * @param string $type The cache type. |
||
92 | * @throws InvalidArgumentException If the type is not a string. |
||
93 | * @return CacheConfig Chainable |
||
94 | */ |
||
95 | public function addType($type) |
||
105 | |||
106 | /** |
||
107 | * @return array |
||
108 | */ |
||
109 | public function types() |
||
113 | |||
114 | /** |
||
115 | * @param integer $ttl The time-to-live, in seconds. |
||
116 | * @throws InvalidArgumentException If the TTL argument is not numeric. |
||
117 | * @return CacheConfig Chainable |
||
118 | */ |
||
119 | public function setDefaultTtl($ttl) |
||
129 | |||
130 | /** |
||
131 | * @return integer |
||
132 | */ |
||
133 | public function defaultTtl() |
||
137 | |||
138 | /** |
||
139 | * @param string $prefix The cache prefix (or namespace). |
||
140 | * @throws InvalidArgumentException If the prefix is not a string. |
||
141 | * @return CacheConfig Chainable |
||
142 | */ |
||
143 | public function setPrefix($prefix) |
||
153 | |||
154 | /** |
||
155 | * @return string |
||
156 | */ |
||
157 | public function prefix() |
||
161 | } |
||
162 |