MDL-40903 cache: coding style tidyup pre-integration
[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.
10aabcb2 33 // The persistent max 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,
083fa877 39 'persistentdata' => true,
10aabcb2 40 'persistentmaxsize' => 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,
49 'persistent' => true,
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 ),
083fa877 61 'persistentdata' => true,
10aabcb2 62 'persistentmaxsize' => 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,
083fa877 74 'persistentdata' => 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,
083fa877 106 'persistentdata' => 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.
083fa877 117 'persistentdata' => true, // Likely there will be a couple of calls to this.
e17dbeeb 118 'persistmaxsize' => 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,
083fa877 126 'persistentdata' => true,
aa135c4d
ARN
127 ),
128
129 // YUI Module cache.
130 // This stores the YUI module metadata for Shifted YUI modules in Moodle.
131 'yuimodules' => array(
132 'mode' => cache_store::MODE_APPLICATION,
aa135c4d 133 ),
c2eb74df 134
d8a1f426
PS
135 // Cache for the list of event observers.
136 'observers' => array(
137 'mode' => cache_store::MODE_APPLICATION,
138 'simplekeys' => true,
139 'simpledata' => true,
083fa877 140 'persistentdata' => true,
d8a1f426
PS
141 'persistentmaxsize' => 2,
142 ),
143
bde002b8
PS
144 // Cache used by the {@link plugin_manager} class.
145 // NOTE: this must be a shared cache.
146 'plugin_manager' => array(
ad3ed98b
DM
147 'mode' => cache_store::MODE_APPLICATION,
148 'simplekeys' => true,
149 'simpledata' => true,
083fa877
SH
150 'persistentdata' => true,
151 'persistentmaxsize' => 2,
ad3ed98b
DM
152 ),
153
083fa877
SH
154 // Cache used by the {@link plugininfo_mod} class.
155 'plugininfo_mod' => array(
156 'mode' => cache_store::MODE_APPLICATION,
157 'simplekeys' => true,
158 'simpledata' => true,
159 'persistentdata' => true,
160 'persistentmaxsize' => 1,
161 ),
162
163 // Cache used by the {@link plugininfo_block} class.
164 'plugininfo_block' => array(
165 'mode' => cache_store::MODE_APPLICATION,
166 'simplekeys' => true,
167 'simpledata' => true,
168 'persistentdata' => true,
169 'persistentmaxsize' => 1,
170 ),
171
172 // Cache used by the {@link plugininfo_filter} class.
173 'plugininfo_filter' => array(
174 'mode' => cache_store::MODE_APPLICATION,
175 'simplekeys' => true,
176 'simpledata' => true,
177 'persistentdata' => true,
178 'persistentmaxsize' => 1,
179 ),
180
181 // Cache used by the {@link plugininfo_repository} class.
182 'plugininfo_repository' => array(
183 'mode' => cache_store::MODE_APPLICATION,
184 'simplekeys' => true,
185 'simpledata' => true,
186 'persistentdata' => true,
187 'persistentmaxsize' => 1,
188 ),
189
190 // Cache used by the {@link plugininfo_portfolio} class.
191 'plugininfo_portfolio' => array(
192 'mode' => cache_store::MODE_APPLICATION,
193 'simplekeys' => true,
194 'simpledata' => true,
195 'persistentdata' => true,
196 'persistentmaxsize' => 1,
197>>>>>>> MDL-40903 cache: converted persistent into persistentdata
198 ),
199
200 // Used to store the full tree of course categories.
eabbfa82 201 'coursecattree' => array(
b33389d2 202 'mode' => cache_store::MODE_APPLICATION,
083fa877 203 'persistentdata' => true,
eabbfa82
MG
204 'invalidationevents' => array(
205 'changesincoursecat',
206 )
207 ),
083fa877 208 // Used to store data for course categories visible to current user. Helps to browse list of categories.
eabbfa82
MG
209 'coursecat' => array(
210 'mode' => cache_store::MODE_SESSION,
eabbfa82
MG
211 'invalidationevents' => array(
212 'changesincoursecat',
213 'changesincourse',
214 ),
215 'ttl' => 600,
216 ),
083fa877 217 // Used to store data for course categories visible to current user. Helps to browse list of categories.
eabbfa82
MG
218 'coursecatrecords' => array(
219 'mode' => cache_store::MODE_REQUEST,
b33389d2 220 'simplekeys' => true,
eabbfa82
MG
221 'invalidationevents' => array(
222 'changesincoursecat',
223 ),
b33389d2 224 ),
083fa877 225 // Cache course contacts for the courses.
36ba8fde
MG
226 'coursecontacts' => array(
227 'mode' => cache_store::MODE_APPLICATION,
083fa877 228 'persistentdata' => true,
36ba8fde
MG
229 'simplekeys' => true,
230 ),
083fa877 231 // Used to store data for repositories to avoid repetitive DB queries within one request.
118ca9e9
MG
232 'repositories' => array(
233 'mode' => cache_store::MODE_REQUEST,
118ca9e9 234 ),
2d3c0fae
YB
235 // Used to store external badges.
236 'externalbadges' => array(
237 'mode' => cache_store::MODE_APPLICATION,
238 'simplekeys' => true,
239 'ttl' => 3600,
240 ),
299cfee5
MG
241 // Accumulated information about course modules and sections used to print course view page (user-independed).
242 // Used in function get_fast_modinfo(), reset in function rebuild_course_cache().
243 'coursemodinfo' => array(
244 'mode' => cache_store::MODE_APPLICATION,
245 'simplekeys' => true,
246 ),
d6a1f63b 247);