MDL-50851 core_tag: introduce tag collections
[moodle.git] / lib / db / caches.php
CommitLineData
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.
598a82c9 34 // NOTE: this data may be safely stored in local caches on cluster nodes.
d6a1f63b
SH
35 'string' => array(
36 'mode' => cache_store::MODE_APPLICATION,
47834bcd 37 'simplekeys' => true,
2e1e266c 38 'simpledata' => true,
d074fb09
SH
39 'staticacceleration' => true,
40 'staticaccelerationsize' => 30
d6a1f63b 41 ),
a560d636 42
598a82c9
PS
43 // Used to store cache of all available translations.
44 // NOTE: this data may be safely stored in local caches on cluster nodes.
45 'langmenu' => array(
46 'mode' => cache_store::MODE_APPLICATION,
47 'simplekeys' => true,
48 'simpledata' => true,
b51fed38 49 'staticacceleration' => 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 ),
d074fb09
SH
61 'staticacceleration' => true,
62 'staticaccelerationsize' => 15
d6a1f63b 63 ),
a560d636 64
170f821b 65 // Event invalidation cache.
47834bcd
SH
66 // This cache is used to manage event invalidation, its keys are the event names.
67 // Whenever something is invalidated it is both purged immediately and an event record created with the timestamp.
68 // When a new cache is initialised all timestamps are looked at and if past data is once more invalidated.
69 // Data guarantee is required in order to ensure invalidation always occurs.
70 // Persistence has been turned on as normally events are used for frequently used caches and this event invalidation
71 // cache will likely be used either lots or never.
d6a1f63b
SH
72 'eventinvalidation' => array(
73 'mode' => cache_store::MODE_APPLICATION,
d074fb09 74 'staticacceleration' => true,
2e1e266c
SH
75 'requiredataguarantee' => true,
76 'simpledata' => true,
a560d636
TH
77 ),
78
79 // Cache for question definitions. This is used by the question_bank class.
80 // Users probably do not need to know about this cache. They will just call
81 // question_bank::load_question.
82 'questiondata' => array(
83 'mode' => cache_store::MODE_APPLICATION,
47834bcd 84 'simplekeys' => true, // The id of the question is used.
a560d636
TH
85 'requiredataguarantee' => false,
86 'datasource' => 'question_finder',
87 'datasourcefile' => 'question/engine/bank.php',
88 ),
e85c56cc
SH
89
90 // HTML Purifier cache
91 // This caches the html purifier cleaned text. This is done because the text is usually cleaned once for every user
10aabcb2 92 // and context combo. Text caching handles caching for the combination, this cache is responsible for caching the
e85c56cc 93 // cleaned text which is shareable.
528a7b44 94 // NOTE: this data may be safely stored in local caches on cluster nodes.
e85c56cc
SH
95 'htmlpurifier' => array(
96 'mode' => cache_store::MODE_APPLICATION,
a9135060
EL
97 ),
98
007bfe8b
SH
99 // Used to store data from the config + config_plugins table in the database.
100 // The key used is the component:
101 // - core for all core config settings
102 // - plugin component for all plugin settings.
103 // Persistence is used because normally several settings within a script.
104 'config' => array(
105 'mode' => cache_store::MODE_APPLICATION,
d074fb09 106 'staticacceleration' => true,
007bfe8b
SH
107 'simpledata' => true
108 ),
e17dbeeb
SH
109
110 // Groupings belonging to a course.
111 // A simple cache designed to replace $GROUPLIB_CACHE->groupings.
112 // Items are organised by course id and are essentially course records.
113 'groupdata' => array(
114 'mode' => cache_store::MODE_APPLICATION,
115 'simplekeys' => true, // The course id the groupings exist for.
116 'simpledata' => true, // Array of stdClass objects containing only strings.
d074fb09 117 'staticacceleration' => true, // Likely there will be a couple of calls to this.
b51fed38 118 'staticaccelerationsize' => 2, // The original cache used 1, we've increased that to two.
59573bb4 119 ),
dbaaeb93
DM
120
121 // Used to cache calendar subscriptions.
e73b527c
AA
122 'calendar_subscriptions' => array(
123 'mode' => cache_store::MODE_APPLICATION,
36546841
SH
124 'simplekeys' => true,
125 'simpledata' => true,
d074fb09 126 'staticacceleration' => true,
aa135c4d
ARN
127 ),
128
aa701743
TL
129 // Cache the capabilities list DB table. See get_all_capabilities in accesslib.
130 'capabilities' => array(
131 'mode' => cache_store::MODE_APPLICATION,
132 'simplekeys' => true,
133 'simpledata' => true,
134 'staticacceleration' => true,
135 'staticaccelerationsize' => 1,
136 'ttl' => 3600, // Just in case.
137 ),
138
aa135c4d
ARN
139 // YUI Module cache.
140 // This stores the YUI module metadata for Shifted YUI modules in Moodle.
141 'yuimodules' => array(
142 'mode' => cache_store::MODE_APPLICATION,
aa135c4d 143 ),
c2eb74df 144
d8a1f426
PS
145 // Cache for the list of event observers.
146 'observers' => array(
147 'mode' => cache_store::MODE_APPLICATION,
148 'simplekeys' => true,
149 'simpledata' => true,
d074fb09
SH
150 'staticacceleration' => true,
151 'staticaccelerationsize' => 2,
d8a1f426
PS
152 ),
153
e87214bd 154 // Cache used by the {@link core_plugin_manager} class.
bde002b8
PS
155 // NOTE: this must be a shared cache.
156 'plugin_manager' => array(
ad3ed98b
DM
157 'mode' => cache_store::MODE_APPLICATION,
158 'simplekeys' => true,
159 'simpledata' => true,
083fa877
SH
160 ),
161
162 // Used to store the full tree of course categories.
eabbfa82 163 'coursecattree' => array(
b33389d2 164 'mode' => cache_store::MODE_APPLICATION,
d074fb09 165 'staticacceleration' => true,
eabbfa82
MG
166 'invalidationevents' => array(
167 'changesincoursecat',
168 )
169 ),
083fa877 170 // Used to store data for course categories visible to current user. Helps to browse list of categories.
eabbfa82
MG
171 'coursecat' => array(
172 'mode' => cache_store::MODE_SESSION,
eabbfa82
MG
173 'invalidationevents' => array(
174 'changesincoursecat',
175 'changesincourse',
176 ),
177 'ttl' => 600,
178 ),
083fa877 179 // Used to store data for course categories visible to current user. Helps to browse list of categories.
eabbfa82
MG
180 'coursecatrecords' => array(
181 'mode' => cache_store::MODE_REQUEST,
b33389d2 182 'simplekeys' => true,
eabbfa82
MG
183 'invalidationevents' => array(
184 'changesincoursecat',
185 ),
b33389d2 186 ),
083fa877 187 // Cache course contacts for the courses.
36ba8fde
MG
188 'coursecontacts' => array(
189 'mode' => cache_store::MODE_APPLICATION,
d074fb09 190 'staticacceleration' => true,
36ba8fde 191 'simplekeys' => true,
a6d4a363 192 'ttl' => 3600,
36ba8fde 193 ),
083fa877 194 // Used to store data for repositories to avoid repetitive DB queries within one request.
118ca9e9
MG
195 'repositories' => array(
196 'mode' => cache_store::MODE_REQUEST,
118ca9e9 197 ),
2d3c0fae
YB
198 // Used to store external badges.
199 'externalbadges' => array(
200 'mode' => cache_store::MODE_APPLICATION,
201 'simplekeys' => true,
202 'ttl' => 3600,
203 ),
299cfee5
MG
204 // Accumulated information about course modules and sections used to print course view page (user-independed).
205 // Used in function get_fast_modinfo(), reset in function rebuild_course_cache().
206 'coursemodinfo' => array(
207 'mode' => cache_store::MODE_APPLICATION,
208 'simplekeys' => true,
209 ),
df460b5a
SH
210 // This is the session user selections cache.
211 // It's a special cache that is used to record user selections that should persist for the lifetime of the session.
212 // Things such as which categories the user has expanded can be stored here.
213 // It uses simple keys and simple data, please ensure all uses conform to those two constraints.
214 'userselections' => array(
215 'mode' => cache_store::MODE_SESSION,
216 'simplekeys' => true,
217 'simpledata' => true
218 ),
cbd063f4 219
3871db0a
MW
220 // Used to cache activity completion status.
221 'completion' => array(
222 'mode' => cache_store::MODE_APPLICATION,
223 'simplekeys' => true,
0cc9d709
MG
224 'ttl' => 3600,
225 'staticacceleration' => true,
226 'staticaccelerationsize' => 2, // Should be current course and site course.
3871db0a
MW
227 ),
228
cbd063f4
SH
229 // A simple cache that stores whether a user can expand a course in the navigation.
230 // The key is the course ID and the value will either be 1 or 0 (cast to bool).
231 // The cache isn't always up to date, it should only ever be used to save a costly call to
232 // can_access_course on the first page request a user makes.
233 'navigation_expandcourse' => array(
234 'mode' => cache_store::MODE_SESSION,
235 'simplekeys' => true,
236 'simpledata' => true
eeb9ee8e
DB
237 ),
238
03ecddb4
SH
239 // Caches suspended userids by course.
240 // The key is the courseid, the value is an array of user ids.
241 'suspended_userids' => array(
eeb9ee8e
DB
242 'mode' => cache_store::MODE_REQUEST,
243 'simplekeys' => true,
244 'simpledata' => true,
245 ),
9effa148
DM
246
247 // Caches plugins existing functions by function name and file.
248 // Set static acceleration size to 5 to load a few functions.
249 'plugin_functions' => array(
250 'mode' => cache_store::MODE_APPLICATION,
251 'simplekeys' => true,
252 'simpledata' => true,
253 'staticacceleration' => true,
254 'staticaccelerationsize' => 5
c026a28d
MG
255 ),
256
257 // Caches data about tag collections and areas.
258 'tags' => array(
259 'mode' => cache_store::MODE_REQUEST,
260 'simplekeys' => true,
9effa148
DM
261 )
262
d6a1f63b 263);