Commit | Line | Data |
---|---|---|
d6a1f63b | 1 | <?php |
167ad91e SH |
2 | // This file is part of Moodle - http://moodle.org/ |
3 | // | |
4 | // Moodle is free software: you can redistribute it and/or modify | |
5 | // it under the terms of the GNU General Public License as published by | |
6 | // the Free Software Foundation, either version 3 of the License, or | |
7 | // (at your option) any later version. | |
8 | // | |
9 | // Moodle is distributed in the hope that it will be useful, | |
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | // GNU General Public License for more details. | |
13 | // | |
14 | // You should have received a copy of the GNU General Public License | |
15 | // along with Moodle. If not, see <http://www.gnu.org/licenses/>. | |
16 | ||
17 | /** | |
18 | * Core cache definitions. | |
19 | * | |
20 | * This file is part of Moodle's cache API, affectionately called MUC. | |
21 | * It contains the components that are requried in order to use caching. | |
22 | * | |
23 | * @package core | |
24 | * @category cache | |
25 | * @copyright 2012 Sam Hemelryk | |
26 | * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | |
27 | */ | |
d6a1f63b SH |
28 | |
29 | $definitions = array( | |
a560d636 | 30 | |
170f821b | 31 | // Used to store processed lang files. |
598a82c9 | 32 | // The keys used are the revision, lang and component of the string file. |
b51fed38 | 33 | // The static acceleration size has been based upon student access of the site. |
d6a1f63b SH |
34 | 'string' => array( |
35 | 'mode' => cache_store::MODE_APPLICATION, | |
47834bcd | 36 | 'simplekeys' => true, |
2e1e266c | 37 | 'simpledata' => true, |
d074fb09 | 38 | 'staticacceleration' => true, |
4350192a | 39 | 'staticaccelerationsize' => 30, |
ae3c6ee4 | 40 | 'canuselocalstore' => true, |
d6a1f63b | 41 | ), |
a560d636 | 42 | |
598a82c9 | 43 | // Used to store cache of all available translations. |
598a82c9 PS |
44 | 'langmenu' => array( |
45 | 'mode' => cache_store::MODE_APPLICATION, | |
46 | 'simplekeys' => true, | |
47 | 'simpledata' => true, | |
b51fed38 | 48 | 'staticacceleration' => true, |
ae3c6ee4 | 49 | 'canuselocalstore' => true, |
598a82c9 PS |
50 | ), |
51 | ||
170f821b | 52 | // Used to store database meta information. |
47834bcd SH |
53 | // The database meta information includes information about tables and there columns. |
54 | // Its keys are the table names. | |
55 | // When creating an instance of this definition you must provide the database family that is being used. | |
d6a1f63b SH |
56 | 'databasemeta' => array( |
57 | 'mode' => cache_store::MODE_APPLICATION, | |
58 | 'requireidentifiers' => array( | |
59 | 'dbfamily' | |
60 | ), | |
d22a01fd | 61 | 'simpledata' => true, // This is a read only class, so leaving references in place is safe. |
d074fb09 SH |
62 | 'staticacceleration' => true, |
63 | 'staticaccelerationsize' => 15 | |
d6a1f63b | 64 | ), |
a560d636 | 65 | |
170f821b | 66 | // Event invalidation cache. |
47834bcd SH |
67 | // This cache is used to manage event invalidation, its keys are the event names. |
68 | // Whenever something is invalidated it is both purged immediately and an event record created with the timestamp. | |
69 | // When a new cache is initialised all timestamps are looked at and if past data is once more invalidated. | |
70 | // Data guarantee is required in order to ensure invalidation always occurs. | |
71 | // Persistence has been turned on as normally events are used for frequently used caches and this event invalidation | |
72 | // cache will likely be used either lots or never. | |
d6a1f63b SH |
73 | 'eventinvalidation' => array( |
74 | 'mode' => cache_store::MODE_APPLICATION, | |
d074fb09 | 75 | 'staticacceleration' => true, |
2e1e266c SH |
76 | 'requiredataguarantee' => true, |
77 | 'simpledata' => true, | |
a560d636 TH |
78 | ), |
79 | ||
80 | // Cache for question definitions. This is used by the question_bank class. | |
81 | // Users probably do not need to know about this cache. They will just call | |
82 | // question_bank::load_question. | |
83 | 'questiondata' => array( | |
84 | 'mode' => cache_store::MODE_APPLICATION, | |
47834bcd | 85 | 'simplekeys' => true, // The id of the question is used. |
a560d636 TH |
86 | 'requiredataguarantee' => false, |
87 | 'datasource' => 'question_finder', | |
88 | 'datasourcefile' => 'question/engine/bank.php', | |
89 | ), | |
e85c56cc SH |
90 | |
91 | // HTML Purifier cache | |
92 | // This caches the html purifier cleaned text. This is done because the text is usually cleaned once for every user | |
10aabcb2 | 93 | // and context combo. Text caching handles caching for the combination, this cache is responsible for caching the |
e85c56cc SH |
94 | // cleaned text which is shareable. |
95 | 'htmlpurifier' => array( | |
96 | 'mode' => cache_store::MODE_APPLICATION, | |
ae3c6ee4 | 97 | 'canuselocalstore' => true, |
a9135060 EL |
98 | ), |
99 | ||
007bfe8b SH |
100 | // Used to store data from the config + config_plugins table in the database. |
101 | // The key used is the component: | |
102 | // - core for all core config settings | |
103 | // - plugin component for all plugin settings. | |
104 | // Persistence is used because normally several settings within a script. | |
105 | 'config' => array( | |
106 | 'mode' => cache_store::MODE_APPLICATION, | |
d074fb09 | 107 | 'staticacceleration' => true, |
007bfe8b SH |
108 | 'simpledata' => true |
109 | ), | |
e17dbeeb SH |
110 | |
111 | // Groupings belonging to a course. | |
112 | // A simple cache designed to replace $GROUPLIB_CACHE->groupings. | |
113 | // Items are organised by course id and are essentially course records. | |
114 | 'groupdata' => array( | |
115 | 'mode' => cache_store::MODE_APPLICATION, | |
116 | 'simplekeys' => true, // The course id the groupings exist for. | |
117 | 'simpledata' => true, // Array of stdClass objects containing only strings. | |
d074fb09 | 118 | 'staticacceleration' => true, // Likely there will be a couple of calls to this. |
b51fed38 | 119 | 'staticaccelerationsize' => 2, // The original cache used 1, we've increased that to two. |
59573bb4 | 120 | ), |
dbaaeb93 DM |
121 | |
122 | // Used to cache calendar subscriptions. | |
e73b527c AA |
123 | 'calendar_subscriptions' => array( |
124 | 'mode' => cache_store::MODE_APPLICATION, | |
36546841 SH |
125 | 'simplekeys' => true, |
126 | 'simpledata' => true, | |
d074fb09 | 127 | 'staticacceleration' => true, |
aa135c4d ARN |
128 | ), |
129 | ||
aa701743 TL |
130 | // Cache the capabilities list DB table. See get_all_capabilities in accesslib. |
131 | 'capabilities' => array( | |
132 | 'mode' => cache_store::MODE_APPLICATION, | |
133 | 'simplekeys' => true, | |
134 | 'simpledata' => true, | |
135 | 'staticacceleration' => true, | |
136 | 'staticaccelerationsize' => 1, | |
137 | 'ttl' => 3600, // Just in case. | |
138 | ), | |
139 | ||
aa135c4d ARN |
140 | // YUI Module cache. |
141 | // This stores the YUI module metadata for Shifted YUI modules in Moodle. | |
142 | 'yuimodules' => array( | |
143 | 'mode' => cache_store::MODE_APPLICATION, | |
aa135c4d | 144 | ), |
c2eb74df | 145 | |
d8a1f426 PS |
146 | // Cache for the list of event observers. |
147 | 'observers' => array( | |
148 | 'mode' => cache_store::MODE_APPLICATION, | |
149 | 'simplekeys' => true, | |
150 | 'simpledata' => true, | |
d074fb09 SH |
151 | 'staticacceleration' => true, |
152 | 'staticaccelerationsize' => 2, | |
d8a1f426 PS |
153 | ), |
154 | ||
e87214bd | 155 | // Cache used by the {@link core_plugin_manager} class. |
bde002b8 PS |
156 | // NOTE: this must be a shared cache. |
157 | 'plugin_manager' => array( | |
ad3ed98b DM |
158 | 'mode' => cache_store::MODE_APPLICATION, |
159 | 'simplekeys' => true, | |
160 | 'simpledata' => true, | |
083fa877 SH |
161 | ), |
162 | ||
163 | // Used to store the full tree of course categories. | |
eabbfa82 | 164 | 'coursecattree' => array( |
b33389d2 | 165 | 'mode' => cache_store::MODE_APPLICATION, |
d074fb09 | 166 | 'staticacceleration' => true, |
eabbfa82 MG |
167 | 'invalidationevents' => array( |
168 | 'changesincoursecat', | |
169 | ) | |
170 | ), | |
083fa877 | 171 | // Used to store data for course categories visible to current user. Helps to browse list of categories. |
eabbfa82 MG |
172 | 'coursecat' => array( |
173 | 'mode' => cache_store::MODE_SESSION, | |
eabbfa82 MG |
174 | 'invalidationevents' => array( |
175 | 'changesincoursecat', | |
176 | 'changesincourse', | |
177 | ), | |
178 | 'ttl' => 600, | |
179 | ), | |
083fa877 | 180 | // Used to store data for course categories visible to current user. Helps to browse list of categories. |
eabbfa82 MG |
181 | 'coursecatrecords' => array( |
182 | 'mode' => cache_store::MODE_REQUEST, | |
b33389d2 | 183 | 'simplekeys' => true, |
eabbfa82 MG |
184 | 'invalidationevents' => array( |
185 | 'changesincoursecat', | |
186 | ), | |
b33389d2 | 187 | ), |
083fa877 | 188 | // Cache course contacts for the courses. |
36ba8fde MG |
189 | 'coursecontacts' => array( |
190 | 'mode' => cache_store::MODE_APPLICATION, | |
d074fb09 | 191 | 'staticacceleration' => true, |
36ba8fde | 192 | 'simplekeys' => true, |
a6d4a363 | 193 | 'ttl' => 3600, |
36ba8fde | 194 | ), |
083fa877 | 195 | // Used to store data for repositories to avoid repetitive DB queries within one request. |
118ca9e9 MG |
196 | 'repositories' => array( |
197 | 'mode' => cache_store::MODE_REQUEST, | |
118ca9e9 | 198 | ), |
2d3c0fae YB |
199 | // Used to store external badges. |
200 | 'externalbadges' => array( | |
201 | 'mode' => cache_store::MODE_APPLICATION, | |
202 | 'simplekeys' => true, | |
203 | 'ttl' => 3600, | |
204 | ), | |
299cfee5 MG |
205 | // Accumulated information about course modules and sections used to print course view page (user-independed). |
206 | // Used in function get_fast_modinfo(), reset in function rebuild_course_cache(). | |
207 | 'coursemodinfo' => array( | |
208 | 'mode' => cache_store::MODE_APPLICATION, | |
209 | 'simplekeys' => true, | |
ae3c6ee4 | 210 | 'canuselocalstore' => true, |
299cfee5 | 211 | ), |
df460b5a SH |
212 | // This is the session user selections cache. |
213 | // It's a special cache that is used to record user selections that should persist for the lifetime of the session. | |
214 | // Things such as which categories the user has expanded can be stored here. | |
215 | // It uses simple keys and simple data, please ensure all uses conform to those two constraints. | |
216 | 'userselections' => array( | |
217 | 'mode' => cache_store::MODE_SESSION, | |
218 | 'simplekeys' => true, | |
219 | 'simpledata' => true | |
220 | ), | |
cbd063f4 | 221 | |
3871db0a MW |
222 | // Used to cache activity completion status. |
223 | 'completion' => array( | |
224 | 'mode' => cache_store::MODE_APPLICATION, | |
225 | 'simplekeys' => true, | |
5c2ef08f | 226 | 'simpledata' => true, |
0cc9d709 MG |
227 | 'ttl' => 3600, |
228 | 'staticacceleration' => true, | |
229 | 'staticaccelerationsize' => 2, // Should be current course and site course. | |
3871db0a MW |
230 | ), |
231 | ||
ddce4f4b DW |
232 | // Used to cache course completion status. |
233 | 'coursecompletion' => array( | |
234 | 'mode' => cache_store::MODE_APPLICATION, | |
235 | 'simplekeys' => true, | |
236 | 'simpledata' => true, | |
237 | 'ttl' => 3600, | |
238 | 'staticacceleration' => true, | |
239 | 'staticaccelerationsize' => 30, // Will be users list of current courses in nav. | |
240 | ), | |
241 | ||
cbd063f4 SH |
242 | // A simple cache that stores whether a user can expand a course in the navigation. |
243 | // The key is the course ID and the value will either be 1 or 0 (cast to bool). | |
244 | // The cache isn't always up to date, it should only ever be used to save a costly call to | |
245 | // can_access_course on the first page request a user makes. | |
246 | 'navigation_expandcourse' => array( | |
247 | 'mode' => cache_store::MODE_SESSION, | |
248 | 'simplekeys' => true, | |
249 | 'simpledata' => true | |
eeb9ee8e DB |
250 | ), |
251 | ||
03ecddb4 SH |
252 | // Caches suspended userids by course. |
253 | // The key is the courseid, the value is an array of user ids. | |
254 | 'suspended_userids' => array( | |
eeb9ee8e DB |
255 | 'mode' => cache_store::MODE_REQUEST, |
256 | 'simplekeys' => true, | |
257 | 'simpledata' => true, | |
258 | ), | |
9effa148 | 259 | |
e705e69e TL |
260 | // Cache system-wide role definitions. |
261 | 'roledefs' => array( | |
262 | 'mode' => cache_store::MODE_APPLICATION, | |
263 | 'simplekeys' => true, | |
264 | 'simpledata' => true, | |
265 | 'staticacceleration' => true, | |
266 | 'staticaccelerationsize' => 30, | |
267 | ), | |
268 | ||
9effa148 DM |
269 | // Caches plugins existing functions by function name and file. |
270 | // Set static acceleration size to 5 to load a few functions. | |
271 | 'plugin_functions' => array( | |
272 | 'mode' => cache_store::MODE_APPLICATION, | |
273 | 'simplekeys' => true, | |
274 | 'simpledata' => true, | |
275 | 'staticacceleration' => true, | |
276 | 'staticaccelerationsize' => 5 | |
c026a28d MG |
277 | ), |
278 | ||
279 | // Caches data about tag collections and areas. | |
280 | 'tags' => array( | |
281 | 'mode' => cache_store::MODE_REQUEST, | |
282 | 'simplekeys' => true, | |
8de48ad0 | 283 | 'staticacceleration' => true, |
db48207e DM |
284 | ), |
285 | ||
8f8517ec | 286 | // Grade categories. Stored at session level as invalidation is very aggressive. |
28774c92 | 287 | 'grade_categories' => array( |
8f8517ec | 288 | 'mode' => cache_store::MODE_SESSION, |
28774c92 | 289 | 'simplekeys' => true, |
8f8517ec DM |
290 | 'invalidationevents' => array( |
291 | 'changesingradecategories', | |
292 | ) | |
28774c92 | 293 | ), |
ef474575 | 294 | |
26e7ecee SL |
295 | // Store temporary tables information. |
296 | 'temp_tables' => array( | |
297 | 'mode' => cache_store::MODE_REQUEST, | |
f18561a2 DM |
298 | 'simplekeys' => true, |
299 | 'simpledata' => true | |
4218ad93 MG |
300 | ), |
301 | ||
302 | // Caches tag index builder results. | |
303 | 'tagindexbuilder' => array( | |
304 | 'mode' => cache_store::MODE_SESSION, | |
305 | 'simplekeys' => true, | |
306 | 'simplevalues' => true, | |
307 | 'staticacceleration' => true, | |
308 | 'staticaccelerationsize' => 10, | |
309 | 'ttl' => 900, // 15 minutes. | |
310 | 'invalidationevents' => array( | |
311 | 'resettagindexbuilder', | |
312 | ), | |
313 | ), | |
20ab51fd | 314 | |
1611308b DM |
315 | // Caches contexts with insights. |
316 | 'contextwithinsights' => array( | |
40fcb365 DM |
317 | 'mode' => cache_store::MODE_APPLICATION, |
318 | 'simplekeys' => true, | |
319 | 'simpledata' => true, | |
320 | 'staticacceleration' => true, | |
321 | 'staticaccelerationsize' => 1 | |
322 | ), | |
323 | ||
20ab51fd AA |
324 | // Caches message processors. |
325 | 'message_processors_enabled' => array( | |
326 | 'mode' => cache_store::MODE_APPLICATION, | |
327 | 'simplekeys' => true, | |
328 | 'simpledata' => true, | |
329 | 'staticacceleration' => true, | |
330 | 'staticaccelerationsize' => 3 | |
331 | ), | |
fb1469d8 | 332 | |
ffd7798c MN |
333 | // Caches the time of the last message between two users. |
334 | 'message_time_last_message_between_users' => array( | |
fb1469d8 RW |
335 | 'mode' => cache_store::MODE_APPLICATION, |
336 | 'simplekeys' => true, // The id of the sender and recipient is used. | |
337 | 'simplevalues' => true, | |
ffd7798c | 338 | 'datasource' => '\core_message\time_last_message_between_users', |
fb1469d8 | 339 | ), |
7e8940b5 DW |
340 | |
341 | // Caches font awesome icons. | |
342 | 'fontawesomeiconmapping' => array( | |
343 | 'mode' => cache_store::MODE_APPLICATION, | |
344 | 'simplekeys' => true, | |
345 | 'simpledata' => true, | |
346 | 'staticacceleration' => true, | |
347 | 'staticaccelerationsize' => 1 | |
348 | ), | |
349 | ||
4cc2f33b SL |
350 | // Caches processed CSS. |
351 | 'postprocessedcss' => array( | |
352 | 'mode' => cache_store::MODE_APPLICATION, | |
353 | 'simplekeys' => true, | |
354 | 'simpledata' => true, | |
355 | 'staticacceleration' => false, | |
356 | ), | |
d6a1f63b | 357 | ); |