3 <html lang=
"en" class=
"no-js">
7 <meta name=
"viewport" content=
"width=device-width,initial-scale=1">
12 <link rel=
"shortcut icon" href=
"../../../assets/default.favicon.ico">
13 <meta name=
"generator" content=
"mkdocs-1.1.2, mkdocs-material-7.0.5">
17 <title>Caches - WoltLab Suite Documentation
</title>
21 <link rel=
"stylesheet" href=
"../../../assets/stylesheets/main.77f3fd56.min.css">
24 <link rel=
"stylesheet" href=
"../../../assets/stylesheets/palette.7fa14f5b.min.css">
28 <meta name=
"theme-color" content=
"#009485">
38 <link rel=
"stylesheet" href=
"../../../stylesheets/extra.css">
52 <body dir=
"ltr" data-md-color-scheme=
"" data-md-color-primary=
"teal" data-md-color-accent=
"">
56 <input class=
"md-toggle" data-md-toggle=
"drawer" type=
"checkbox" id=
"__drawer" autocomplete=
"off">
57 <input class=
"md-toggle" data-md-toggle=
"search" type=
"checkbox" id=
"__search" autocomplete=
"off">
58 <label class=
"md-overlay" for=
"__drawer"></label>
59 <div data-md-component=
"skip">
62 <a href=
"#caches" class=
"md-skip">
67 <div data-md-component=
"announce">
69 <aside class=
"md-announce">
70 <div class=
"md-announce__inner md-grid md-typeset">
72 <a href=
"https://www.woltlab.com">Back to
<strong>woltlab.com
</strong></a>
81 <header class=
"md-header" data-md-component=
"header">
82 <nav class=
"md-header__inner md-grid" aria-label=
"Header">
83 <a href=
"../../.." title=
"WoltLab Suite Documentation" class=
"md-header__button md-logo" aria-label=
"WoltLab Suite Documentation">
85 <img src=
"../../../assets/logo.png" alt=
"logo">
88 <label class=
"md-header__button md-icon" for=
"__drawer">
89 <svg xmlns=
"http://www.w3.org/2000/svg" viewBox=
"0 0 24 24"><path d=
"M3 6h18v2H3V6m0 5h18v2H3v-2m0 5h18v2H3v-2z"/></svg>
91 <div class=
"md-header__title" data-md-component=
"header-title">
92 <div class=
"md-header__ellipsis">
93 <div class=
"md-header__topic">
94 <span class=
"md-ellipsis">
95 WoltLab Suite Documentation
98 <div class=
"md-header__topic" data-md-component=
"header-topic">
99 <span class=
"md-ellipsis">
107 <div class=
"md-header__options">
111 <label class=
"md-header__button md-icon" for=
"__search">
112 <svg xmlns=
"http://www.w3.org/2000/svg" viewBox=
"0 0 24 24"><path d=
"M9.5 3A6.5 6.5 0 0 1 16 9.5c0 1.61-.59 3.09-1.56 4.23l.27.27h.79l5 5-1.5 1.5-5-5v-.79l-.27-.27A6.516 6.516 0 0 1 9.5 16 6.5 6.5 0 0 1 3 9.5 6.5 6.5 0 0 1 9.5 3m0 2C7 5 5 7 5 9.5S7 14 9.5 14 14 12 14 9.5 12 5 9.5 5z"/></svg>
115 <div class=
"md-search" data-md-component=
"search" role=
"dialog">
116 <label class=
"md-search__overlay" for=
"__search"></label>
117 <div class=
"md-search__inner" role=
"search">
118 <form class=
"md-search__form" name=
"search">
119 <input type=
"text" class=
"md-search__input" name=
"query" aria-label=
"Search" placeholder=
"Search" autocapitalize=
"off" autocorrect=
"off" autocomplete=
"off" spellcheck=
"false" data-md-component=
"search-query" data-md-state=
"active" required
>
120 <label class=
"md-search__icon md-icon" for=
"__search">
121 <svg xmlns=
"http://www.w3.org/2000/svg" viewBox=
"0 0 24 24"><path d=
"M9.5 3A6.5 6.5 0 0 1 16 9.5c0 1.61-.59 3.09-1.56 4.23l.27.27h.79l5 5-1.5 1.5-5-5v-.79l-.27-.27A6.516 6.516 0 0 1 9.5 16 6.5 6.5 0 0 1 3 9.5 6.5 6.5 0 0 1 9.5 3m0 2C7 5 5 7 5 9.5S7 14 9.5 14 14 12 14 9.5 12 5 9.5 5z"/></svg>
122 <svg xmlns=
"http://www.w3.org/2000/svg" viewBox=
"0 0 24 24"><path d=
"M20 11v2H8l5.5 5.5-1.42 1.42L4.16 12l7.92-7.92L13.5 5.5 8 11h12z"/></svg>
124 <button type=
"reset" class=
"md-search__icon md-icon" aria-label=
"Clear" tabindex=
"-1">
125 <svg xmlns=
"http://www.w3.org/2000/svg" viewBox=
"0 0 24 24"><path d=
"M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12 19 6.41z"/></svg>
128 <div class=
"md-search__output">
129 <div class=
"md-search__scrollwrap" data-md-scrollfix
>
130 <div class=
"md-search-result" data-md-component=
"search-result">
131 <div class=
"md-search-result__meta">
134 <ol class=
"md-search-result__list"></ol>
142 <div class=
"md-header__source">
144 <a href=
"https://github.com/WoltLab/docs.woltlab.com/" title=
"Go to repository" class=
"md-source" data-md-component=
"source">
145 <div class=
"md-source__icon md-icon">
147 <svg xmlns=
"http://www.w3.org/2000/svg" viewBox=
"0 0 448 512"><path d=
"M439.55 236.05L244 40.45a28.87 28.87 0 0 0-40.81 0l-40.66 40.63 51.52 51.52c27.06-9.14 52.68 16.77 43.39 43.68l49.66 49.66c34.23-11.8 61.18 31 35.47 56.69-26.49 26.49-70.21-2.87-56-37.34L240.22 199v121.85c25.3 12.54 22.26 41.85 9.08 55a34.34 34.34 0 0 1-48.55 0c-17.57-17.6-11.07-46.91 11.25-56v-123c-20.8-8.51-24.6-30.74-18.64-45L142.57 101 8.45 235.14a28.86 28.86 0 0 0 0 40.81l195.61 195.6a28.86 28.86 0 0 0 40.8 0l194.69-194.69a28.86 28.86 0 0 0 0-40.81z"/></svg>
149 <div class=
"md-source__repository">
158 <div class=
"md-container" data-md-component=
"container">
163 <main class=
"md-main" data-md-component=
"main">
164 <div class=
"md-main__inner md-grid">
168 <div class=
"md-sidebar md-sidebar--primary" data-md-component=
"sidebar" data-md-type=
"navigation" >
169 <div class=
"md-sidebar__scrollwrap">
170 <div class=
"md-sidebar__inner">
176 <nav class=
"md-nav md-nav--primary" aria-label=
"Navigation" data-md-level=
"0">
177 <label class=
"md-nav__title" for=
"__drawer">
178 <a href=
"../../.." title=
"WoltLab Suite Documentation" class=
"md-nav__button md-logo" aria-label=
"WoltLab Suite Documentation">
180 <img src=
"../../../assets/logo.png" alt=
"logo">
183 WoltLab Suite Documentation
186 <div class=
"md-nav__source">
188 <a href=
"https://github.com/WoltLab/docs.woltlab.com/" title=
"Go to repository" class=
"md-source" data-md-component=
"source">
189 <div class=
"md-source__icon md-icon">
191 <svg xmlns=
"http://www.w3.org/2000/svg" viewBox=
"0 0 448 512"><path d=
"M439.55 236.05L244 40.45a28.87 28.87 0 0 0-40.81 0l-40.66 40.63 51.52 51.52c27.06-9.14 52.68 16.77 43.39 43.68l49.66 49.66c34.23-11.8 61.18 31 35.47 56.69-26.49 26.49-70.21-2.87-56-37.34L240.22 199v121.85c25.3 12.54 22.26 41.85 9.08 55a34.34 34.34 0 0 1-48.55 0c-17.57-17.6-11.07-46.91 11.25-56v-123c-20.8-8.51-24.6-30.74-18.64-45L142.57 101 8.45 235.14a28.86 28.86 0 0 0 0 40.81l195.61 195.6a28.86 28.86 0 0 0 40.8 0l194.69-194.69a28.86 28.86 0 0 0 0-40.81z"/></svg>
193 <div class=
"md-source__repository">
199 <ul class=
"md-nav__list" data-md-scrollfix
>
208 <li class=
"md-nav__item">
209 <a href=
"../../../getting-started/" class=
"md-nav__link">
226 <li class=
"md-nav__item md-nav__item--active md-nav__item--nested">
229 <input class=
"md-nav__toggle md-toggle" data-md-toggle=
"__nav_2" type=
"checkbox" id=
"__nav_2" checked
>
231 <label class=
"md-nav__link" for=
"__nav_2">
233 <span class=
"md-nav__icon md-icon"></span>
235 <nav class=
"md-nav" aria-label=
"PHP API" data-md-level=
"1">
236 <label class=
"md-nav__title" for=
"__nav_2">
237 <span class=
"md-nav__icon md-icon"></span>
240 <ul class=
"md-nav__list" data-md-scrollfix
>
246 <li class=
"md-nav__item">
247 <a href=
"../../pages/" class=
"md-nav__link">
258 <li class=
"md-nav__item">
259 <a href=
"../../database-objects/" class=
"md-nav__link">
270 <li class=
"md-nav__item">
271 <a href=
"../../database-access/" class=
"md-nav__link">
282 <li class=
"md-nav__item">
283 <a href=
"../../exceptions/" class=
"md-nav__link">
297 <li class=
"md-nav__item md-nav__item--active md-nav__item--nested">
300 <input class=
"md-nav__toggle md-toggle" data-md-toggle=
"__nav_2_5" type=
"checkbox" id=
"__nav_2_5" checked
>
302 <label class=
"md-nav__link" for=
"__nav_2_5">
304 <span class=
"md-nav__icon md-icon"></span>
306 <nav class=
"md-nav" aria-label=
"API" data-md-level=
"2">
307 <label class=
"md-nav__title" for=
"__nav_2_5">
308 <span class=
"md-nav__icon md-icon"></span>
311 <ul class=
"md-nav__list" data-md-scrollfix
>
319 <li class=
"md-nav__item md-nav__item--active">
321 <input class=
"md-nav__toggle md-toggle" data-md-toggle=
"toc" type=
"checkbox" id=
"__toc">
326 <label class=
"md-nav__link md-nav__link--active" for=
"__toc">
328 <span class=
"md-nav__icon md-icon"></span>
331 <a href=
"./" class=
"md-nav__link md-nav__link--active">
336 <nav class=
"md-nav md-nav--secondary" aria-label=
"Table of contents">
342 <label class=
"md-nav__title" for=
"__toc">
343 <span class=
"md-nav__icon md-icon"></span>
346 <ul class=
"md-nav__list" data-md-component=
"toc" data-md-scrollfix
>
348 <li class=
"md-nav__item">
349 <a href=
"#understanding-caching" class=
"md-nav__link">
350 Understanding Caching
353 <nav class=
"md-nav" aria-label=
"Understanding Caching">
354 <ul class=
"md-nav__list">
356 <li class=
"md-nav__item">
357 <a href=
"#when-to-use-a-cache" class=
"md-nav__link">
363 <li class=
"md-nav__item">
364 <a href=
"#when-not-to-use-a-cache" class=
"md-nav__link">
365 When not to Use a Cache
387 <li class=
"md-nav__item">
388 <a href=
"../comments/" class=
"md-nav__link">
399 <li class=
"md-nav__item">
400 <a href=
"../cronjobs/" class=
"md-nav__link">
411 <li class=
"md-nav__item">
412 <a href=
"../events/" class=
"md-nav__link">
424 <li class=
"md-nav__item md-nav__item--nested">
427 <input class=
"md-nav__toggle md-toggle" data-md-toggle=
"__nav_2_5_5" type=
"checkbox" id=
"__nav_2_5_5" >
429 <label class=
"md-nav__link" for=
"__nav_2_5_5">
431 <span class=
"md-nav__icon md-icon"></span>
433 <nav class=
"md-nav" aria-label=
"Form Builder" data-md-level=
"3">
434 <label class=
"md-nav__title" for=
"__nav_2_5_5">
435 <span class=
"md-nav__icon md-icon"></span>
438 <ul class=
"md-nav__list" data-md-scrollfix
>
444 <li class=
"md-nav__item">
445 <a href=
"../form_builder/overview/" class=
"md-nav__link">
456 <li class=
"md-nav__item">
457 <a href=
"../form_builder/structure/" class=
"md-nav__link">
468 <li class=
"md-nav__item">
469 <a href=
"../form_builder/form_fields/" class=
"md-nav__link">
480 <li class=
"md-nav__item">
481 <a href=
"../form_builder/validation_data/" class=
"md-nav__link">
492 <li class=
"md-nav__item">
493 <a href=
"../form_builder/dependencies/" class=
"md-nav__link">
510 <li class=
"md-nav__item">
511 <a href=
"../package_installation_plugins/" class=
"md-nav__link">
512 Package Installation Plugins
522 <li class=
"md-nav__item">
523 <a href=
"../user_activity_points/" class=
"md-nav__link">
534 <li class=
"md-nav__item">
535 <a href=
"../user_notifications/" class=
"md-nav__link">
546 <li class=
"md-nav__item">
547 <a href=
"../sitemaps/" class=
"md-nav__link">
564 <li class=
"md-nav__item">
565 <a href=
"../../code-style/" class=
"md-nav__link">
576 <li class=
"md-nav__item">
577 <a href=
"../../apps/" class=
"md-nav__link">
588 <li class=
"md-nav__item">
589 <a href=
"../../gdpr/" class=
"md-nav__link">
610 <li class=
"md-nav__item md-nav__item--nested">
613 <input class=
"md-nav__toggle md-toggle" data-md-toggle=
"__nav_3" type=
"checkbox" id=
"__nav_3" >
615 <label class=
"md-nav__link" for=
"__nav_3">
616 Languages, Templates & CSS
617 <span class=
"md-nav__icon md-icon"></span>
619 <nav class=
"md-nav" aria-label=
"Languages, Templates & CSS" data-md-level=
"1">
620 <label class=
"md-nav__title" for=
"__nav_3">
621 <span class=
"md-nav__icon md-icon"></span>
622 Languages, Templates & CSS
624 <ul class=
"md-nav__list" data-md-scrollfix
>
630 <li class=
"md-nav__item">
631 <a href=
"../../../view/languages/" class=
"md-nav__link">
642 <li class=
"md-nav__item">
643 <a href=
"../../../view/templates/" class=
"md-nav__link">
654 <li class=
"md-nav__item">
655 <a href=
"../../../view/css/" class=
"md-nav__link">
676 <li class=
"md-nav__item md-nav__item--nested">
679 <input class=
"md-nav__toggle md-toggle" data-md-toggle=
"__nav_4" type=
"checkbox" id=
"__nav_4" >
681 <label class=
"md-nav__link" for=
"__nav_4">
683 <span class=
"md-nav__icon md-icon"></span>
685 <nav class=
"md-nav" aria-label=
"JavaScript API" data-md-level=
"1">
686 <label class=
"md-nav__title" for=
"__nav_4">
687 <span class=
"md-nav__icon md-icon"></span>
690 <ul class=
"md-nav__list" data-md-scrollfix
>
696 <li class=
"md-nav__item">
697 <a href=
"../../../javascript/general-usage/" class=
"md-nav__link">
709 <li class=
"md-nav__item md-nav__item--nested">
712 <input class=
"md-nav__toggle md-toggle" data-md-toggle=
"__nav_4_2" type=
"checkbox" id=
"__nav_4_2" >
714 <label class=
"md-nav__link" for=
"__nav_4_2">
716 <span class=
"md-nav__icon md-icon"></span>
718 <nav class=
"md-nav" aria-label=
"New API" data-md-level=
"2">
719 <label class=
"md-nav__title" for=
"__nav_4_2">
720 <span class=
"md-nav__icon md-icon"></span>
723 <ul class=
"md-nav__list" data-md-scrollfix
>
729 <li class=
"md-nav__item">
730 <a href=
"../../../javascript/new-api_writing-a-module/" class=
"md-nav__link">
741 <li class=
"md-nav__item">
742 <a href=
"../../../javascript/new-api_data-structures/" class=
"md-nav__link">
753 <li class=
"md-nav__item">
754 <a href=
"../../../javascript/new-api_core/" class=
"md-nav__link">
765 <li class=
"md-nav__item">
766 <a href=
"../../../javascript/new-api_dom/" class=
"md-nav__link">
777 <li class=
"md-nav__item">
778 <a href=
"../../../javascript/new-api_events/" class=
"md-nav__link">
789 <li class=
"md-nav__item">
790 <a href=
"../../../javascript/new-api_ajax/" class=
"md-nav__link">
801 <li class=
"md-nav__item">
802 <a href=
"../../../javascript/new-api_dialogs/" class=
"md-nav__link">
813 <li class=
"md-nav__item">
814 <a href=
"../../../javascript/new-api_browser/" class=
"md-nav__link">
815 Browser and Screen Sizes
825 <li class=
"md-nav__item">
826 <a href=
"../../../javascript/new-api_ui/" class=
"md-nav__link">
843 <li class=
"md-nav__item">
844 <a href=
"../../../javascript/legacy-api/" class=
"md-nav__link">
855 <li class=
"md-nav__item">
856 <a href=
"../../../javascript/helper-functions/" class=
"md-nav__link">
867 <li class=
"md-nav__item">
868 <a href=
"../../../javascript/code-snippets/" class=
"md-nav__link">
889 <li class=
"md-nav__item md-nav__item--nested">
892 <input class=
"md-nav__toggle md-toggle" data-md-toggle=
"__nav_5" type=
"checkbox" id=
"__nav_5" >
894 <label class=
"md-nav__link" for=
"__nav_5">
896 <span class=
"md-nav__icon md-icon"></span>
898 <nav class=
"md-nav" aria-label=
"Package Components" data-md-level=
"1">
899 <label class=
"md-nav__title" for=
"__nav_5">
900 <span class=
"md-nav__icon md-icon"></span>
903 <ul class=
"md-nav__list" data-md-scrollfix
>
909 <li class=
"md-nav__item">
910 <a href=
"../../../package/package-xml/" class=
"md-nav__link">
922 <li class=
"md-nav__item md-nav__item--nested">
925 <input class=
"md-nav__toggle md-toggle" data-md-toggle=
"__nav_5_2" type=
"checkbox" id=
"__nav_5_2" >
927 <label class=
"md-nav__link" for=
"__nav_5_2">
929 <span class=
"md-nav__icon md-icon"></span>
931 <nav class=
"md-nav" aria-label=
"PIPs" data-md-level=
"2">
932 <label class=
"md-nav__title" for=
"__nav_5_2">
933 <span class=
"md-nav__icon md-icon"></span>
936 <ul class=
"md-nav__list" data-md-scrollfix
>
942 <li class=
"md-nav__item">
943 <a href=
"../../../package/pip/" class=
"md-nav__link">
954 <li class=
"md-nav__item">
955 <a href=
"../../../package/pip/acl-option/" class=
"md-nav__link">
966 <li class=
"md-nav__item">
967 <a href=
"../../../package/pip/acp-menu/" class=
"md-nav__link">
978 <li class=
"md-nav__item">
979 <a href=
"../../../package/pip/acp-search-provider/" class=
"md-nav__link">
990 <li class=
"md-nav__item">
991 <a href=
"../../../package/pip/acp-template/" class=
"md-nav__link">
1002 <li class=
"md-nav__item">
1003 <a href=
"../../../package/pip/bbcode/" class=
"md-nav__link">
1014 <li class=
"md-nav__item">
1015 <a href=
"../../../package/pip/box/" class=
"md-nav__link">
1026 <li class=
"md-nav__item">
1027 <a href=
"../../../package/pip/clipboard-action/" class=
"md-nav__link">
1038 <li class=
"md-nav__item">
1039 <a href=
"../../../package/pip/core-object/" class=
"md-nav__link">
1050 <li class=
"md-nav__item">
1051 <a href=
"../../../package/pip/cronjob/" class=
"md-nav__link">
1062 <li class=
"md-nav__item">
1063 <a href=
"../../../package/pip/event-listener/" class=
"md-nav__link">
1074 <li class=
"md-nav__item">
1075 <a href=
"../../../package/pip/file/" class=
"md-nav__link">
1086 <li class=
"md-nav__item">
1087 <a href=
"../../../package/pip/language/" class=
"md-nav__link">
1098 <li class=
"md-nav__item">
1099 <a href=
"../../../package/pip/media-provider/" class=
"md-nav__link">
1110 <li class=
"md-nav__item">
1111 <a href=
"../../../package/pip/menu/" class=
"md-nav__link">
1122 <li class=
"md-nav__item">
1123 <a href=
"../../../package/pip/menu-item/" class=
"md-nav__link">
1134 <li class=
"md-nav__item">
1135 <a href=
"../../../package/pip/object-type/" class=
"md-nav__link">
1146 <li class=
"md-nav__item">
1147 <a href=
"../../../package/pip/object-type-definition/" class=
"md-nav__link">
1148 objectTypeDefinition
1158 <li class=
"md-nav__item">
1159 <a href=
"../../../package/pip/option/" class=
"md-nav__link">
1170 <li class=
"md-nav__item">
1171 <a href=
"../../../package/pip/page/" class=
"md-nav__link">
1182 <li class=
"md-nav__item">
1183 <a href=
"../../../package/pip/pip/" class=
"md-nav__link">
1194 <li class=
"md-nav__item">
1195 <a href=
"../../../package/pip/script/" class=
"md-nav__link">
1206 <li class=
"md-nav__item">
1207 <a href=
"../../../package/pip/smiley/" class=
"md-nav__link">
1218 <li class=
"md-nav__item">
1219 <a href=
"../../../package/pip/sql/" class=
"md-nav__link">
1230 <li class=
"md-nav__item">
1231 <a href=
"../../../package/pip/style/" class=
"md-nav__link">
1242 <li class=
"md-nav__item">
1243 <a href=
"../../../package/pip/template/" class=
"md-nav__link">
1254 <li class=
"md-nav__item">
1255 <a href=
"../../../package/pip/template-listener/" class=
"md-nav__link">
1266 <li class=
"md-nav__item">
1267 <a href=
"../../../package/pip/user-group-option/" class=
"md-nav__link">
1278 <li class=
"md-nav__item">
1279 <a href=
"../../../package/pip/user-menu/" class=
"md-nav__link">
1290 <li class=
"md-nav__item">
1291 <a href=
"../../../package/pip/user-notification-event/" class=
"md-nav__link">
1292 userNotificationEvent
1302 <li class=
"md-nav__item">
1303 <a href=
"../../../package/pip/user-option/" class=
"md-nav__link">
1314 <li class=
"md-nav__item">
1315 <a href=
"../../../package/pip/user-profile-menu/" class=
"md-nav__link">
1332 <li class=
"md-nav__item">
1333 <a href=
"../../../package/database-php-api/" class=
"md-nav__link">
1354 <li class=
"md-nav__item md-nav__item--nested">
1357 <input class=
"md-nav__toggle md-toggle" data-md-toggle=
"__nav_6" type=
"checkbox" id=
"__nav_6" >
1359 <label class=
"md-nav__link" for=
"__nav_6">
1361 <span class=
"md-nav__icon md-icon"></span>
1363 <nav class=
"md-nav" aria-label=
"Migration" data-md-level=
"1">
1364 <label class=
"md-nav__title" for=
"__nav_6">
1365 <span class=
"md-nav__icon md-icon"></span>
1368 <ul class=
"md-nav__list" data-md-scrollfix
>
1375 <li class=
"md-nav__item md-nav__item--nested">
1378 <input class=
"md-nav__toggle md-toggle" data-md-toggle=
"__nav_6_1" type=
"checkbox" id=
"__nav_6_1" >
1380 <label class=
"md-nav__link" for=
"__nav_6_1">
1381 Migrating from WSC
5.3
1382 <span class=
"md-nav__icon md-icon"></span>
1384 <nav class=
"md-nav" aria-label=
"Migrating from WSC 5.3" data-md-level=
"2">
1385 <label class=
"md-nav__title" for=
"__nav_6_1">
1386 <span class=
"md-nav__icon md-icon"></span>
1387 Migrating from WSC
5.3
1389 <ul class=
"md-nav__list" data-md-scrollfix
>
1395 <li class=
"md-nav__item">
1396 <a href=
"../../../migration/wsc53/php/" class=
"md-nav__link">
1407 <li class=
"md-nav__item">
1408 <a href=
"../../../migration/wsc53/session/" class=
"md-nav__link">
1409 Session Handling and Authentication
1419 <li class=
"md-nav__item">
1420 <a href=
"../../../migration/wsc53/javascript/" class=
"md-nav__link">
1431 <li class=
"md-nav__item">
1432 <a href=
"../../../migration/wsc53/templates/" class=
"md-nav__link">
1443 <li class=
"md-nav__item">
1444 <a href=
"../../../migration/wsc53/libraries/" class=
"md-nav__link">
1445 Third Party Libraries
1462 <li class=
"md-nav__item md-nav__item--nested">
1465 <input class=
"md-nav__toggle md-toggle" data-md-toggle=
"__nav_6_2" type=
"checkbox" id=
"__nav_6_2" >
1467 <label class=
"md-nav__link" for=
"__nav_6_2">
1468 Migrating from WSC
5.2
1469 <span class=
"md-nav__icon md-icon"></span>
1471 <nav class=
"md-nav" aria-label=
"Migrating from WSC 5.2" data-md-level=
"2">
1472 <label class=
"md-nav__title" for=
"__nav_6_2">
1473 <span class=
"md-nav__icon md-icon"></span>
1474 Migrating from WSC
5.2
1476 <ul class=
"md-nav__list" data-md-scrollfix
>
1482 <li class=
"md-nav__item">
1483 <a href=
"../../../migration/wsc52/php/" class=
"md-nav__link">
1494 <li class=
"md-nav__item">
1495 <a href=
"../../../migration/wsc52/templates/" class=
"md-nav__link">
1496 Templates and Languages
1506 <li class=
"md-nav__item">
1507 <a href=
"../../../migration/wsc52/libraries/" class=
"md-nav__link">
1508 Third Party Libraries
1525 <li class=
"md-nav__item md-nav__item--nested">
1528 <input class=
"md-nav__toggle md-toggle" data-md-toggle=
"__nav_6_3" type=
"checkbox" id=
"__nav_6_3" >
1530 <label class=
"md-nav__link" for=
"__nav_6_3">
1531 Migrating from WSC
3.1
1532 <span class=
"md-nav__icon md-icon"></span>
1534 <nav class=
"md-nav" aria-label=
"Migrating from WSC 3.1" data-md-level=
"2">
1535 <label class=
"md-nav__title" for=
"__nav_6_3">
1536 <span class=
"md-nav__icon md-icon"></span>
1537 Migrating from WSC
3.1
1539 <ul class=
"md-nav__list" data-md-scrollfix
>
1545 <li class=
"md-nav__item">
1546 <a href=
"../../../migration/wsc31/php/" class=
"md-nav__link">
1564 <li class=
"md-nav__item md-nav__item--nested">
1567 <input class=
"md-nav__toggle md-toggle" data-md-toggle=
"__nav_6_4" type=
"checkbox" id=
"__nav_6_4" >
1569 <label class=
"md-nav__link" for=
"__nav_6_4">
1570 Migrating from WSC
3.0
1571 <span class=
"md-nav__icon md-icon"></span>
1573 <nav class=
"md-nav" aria-label=
"Migrating from WSC 3.0" data-md-level=
"2">
1574 <label class=
"md-nav__title" for=
"__nav_6_4">
1575 <span class=
"md-nav__icon md-icon"></span>
1576 Migrating from WSC
3.0
1578 <ul class=
"md-nav__list" data-md-scrollfix
>
1584 <li class=
"md-nav__item">
1585 <a href=
"../../../migration/wsc30/php/" class=
"md-nav__link">
1596 <li class=
"md-nav__item">
1597 <a href=
"../../../migration/wsc30/javascript/" class=
"md-nav__link">
1608 <li class=
"md-nav__item">
1609 <a href=
"../../../migration/wsc30/templates/" class=
"md-nav__link">
1620 <li class=
"md-nav__item">
1621 <a href=
"../../../migration/wsc30/css/" class=
"md-nav__link">
1632 <li class=
"md-nav__item">
1633 <a href=
"../../../migration/wsc30/package/" class=
"md-nav__link">
1651 <li class=
"md-nav__item md-nav__item--nested">
1654 <input class=
"md-nav__toggle md-toggle" data-md-toggle=
"__nav_6_5" type=
"checkbox" id=
"__nav_6_5" >
1656 <label class=
"md-nav__link" for=
"__nav_6_5">
1657 Migrating from WCF
2.1
1658 <span class=
"md-nav__icon md-icon"></span>
1660 <nav class=
"md-nav" aria-label=
"Migrating from WCF 2.1" data-md-level=
"2">
1661 <label class=
"md-nav__title" for=
"__nav_6_5">
1662 <span class=
"md-nav__icon md-icon"></span>
1663 Migrating from WCF
2.1
1665 <ul class=
"md-nav__list" data-md-scrollfix
>
1671 <li class=
"md-nav__item">
1672 <a href=
"../../../migration/wcf21/php/" class=
"md-nav__link">
1683 <li class=
"md-nav__item">
1684 <a href=
"../../../migration/wcf21/templates/" class=
"md-nav__link">
1695 <li class=
"md-nav__item">
1696 <a href=
"../../../migration/wcf21/css/" class=
"md-nav__link">
1707 <li class=
"md-nav__item">
1708 <a href=
"../../../migration/wcf21/package/" class=
"md-nav__link">
1735 <li class=
"md-nav__item md-nav__item--nested">
1738 <input class=
"md-nav__toggle md-toggle" data-md-toggle=
"__nav_7" type=
"checkbox" id=
"__nav_7" >
1740 <label class=
"md-nav__link" for=
"__nav_7">
1742 <span class=
"md-nav__icon md-icon"></span>
1744 <nav class=
"md-nav" aria-label=
"Tutorials" data-md-level=
"1">
1745 <label class=
"md-nav__title" for=
"__nav_7">
1746 <span class=
"md-nav__icon md-icon"></span>
1749 <ul class=
"md-nav__list" data-md-scrollfix
>
1756 <li class=
"md-nav__item md-nav__item--nested">
1759 <input class=
"md-nav__toggle md-toggle" data-md-toggle=
"__nav_7_1" type=
"checkbox" id=
"__nav_7_1" >
1761 <label class=
"md-nav__link" for=
"__nav_7_1">
1763 <span class=
"md-nav__icon md-icon"></span>
1765 <nav class=
"md-nav" aria-label=
"Tutorial Series" data-md-level=
"2">
1766 <label class=
"md-nav__title" for=
"__nav_7_1">
1767 <span class=
"md-nav__icon md-icon"></span>
1770 <ul class=
"md-nav__list" data-md-scrollfix
>
1776 <li class=
"md-nav__item">
1777 <a href=
"../../../tutorial/series/overview/" class=
"md-nav__link">
1788 <li class=
"md-nav__item">
1789 <a href=
"../../../tutorial/series/part_1/" class=
"md-nav__link">
1800 <li class=
"md-nav__item">
1801 <a href=
"../../../tutorial/series/part_2/" class=
"md-nav__link">
1812 <li class=
"md-nav__item">
1813 <a href=
"../../../tutorial/series/part_3/" class=
"md-nav__link">
1840 <div class=
"md-sidebar md-sidebar--secondary" data-md-component=
"sidebar" data-md-type=
"toc" >
1841 <div class=
"md-sidebar__scrollwrap">
1842 <div class=
"md-sidebar__inner">
1844 <nav class=
"md-nav md-nav--secondary" aria-label=
"Table of contents">
1850 <label class=
"md-nav__title" for=
"__toc">
1851 <span class=
"md-nav__icon md-icon"></span>
1854 <ul class=
"md-nav__list" data-md-component=
"toc" data-md-scrollfix
>
1856 <li class=
"md-nav__item">
1857 <a href=
"#understanding-caching" class=
"md-nav__link">
1858 Understanding Caching
1861 <nav class=
"md-nav" aria-label=
"Understanding Caching">
1862 <ul class=
"md-nav__list">
1864 <li class=
"md-nav__item">
1865 <a href=
"#when-to-use-a-cache" class=
"md-nav__link">
1871 <li class=
"md-nav__item">
1872 <a href=
"#when-not-to-use-a-cache" class=
"md-nav__link">
1873 When not to Use a Cache
1891 <div class=
"md-content" data-md-component=
"content">
1892 <article class=
"md-content__inner md-typeset">
1895 <a href=
"https://github.com/WoltLab/docs.woltlab.com/edit/5.4/docs/php/api/caches.md" title=
"Edit this page" class=
"md-content__button md-icon">
1896 <svg xmlns=
"http://www.w3.org/2000/svg" viewBox=
"0 0 24 24"><path d=
"M20.71 7.04c.39-.39.39-1.04 0-1.41l-2.34-2.34c-.37-.39-1.02-.39-1.41 0l-1.84 1.83 3.75 3.75M3 17.25V21h3.75L17.81 9.93l-3.75-3.75L3 17.25z"/></svg>
1900 <h1 id=
"caches">Caches
<a class=
"headerlink" href=
"#caches" title=
"Permanent link">#
</a></h1>
1901 <p>WoltLab Suite offers two distinct types of caches:
</p>
1903 <li><a href=
"../caches_persistent-caches/">Persistent caches
</a> created by cache builders whose data can be stored using different cache sources.
</li>
1904 <li><a href=
"../caches_runtime-caches/">Runtime caches
</a> store objects for the duration of a single request.
</li>
1906 <h2 id=
"understanding-caching">Understanding Caching
<a class=
"headerlink" href=
"#understanding-caching" title=
"Permanent link">#
</a></h2>
1907 <p>Every so often, plugins make use of cache builders or runtime caches to store
1908 their data, even if there is absolutely no need for them to do so. Usually, this
1909 involves a strong opinion about the total number of SQL queries on a page,
1910 including but not limited to some magic treshold numbers, which should not be
1911 exceeded for
"performance reasons".
</p>
1912 <p>This misconception can easily lead into thinking that SQL queries should be
1913 avoided or at least written to a cache, so that it doesn't need to be executed
1914 so often. Unfortunately, this completely ignores the fact that both a single
1915 query can take down your app (e. g. full table scan on millions of rows), but
1916 10 queries using a primary key on a table with a few hundred rows will not slow
1918 <p>There are some queries that should go into caches by design, but most of the
1919 cache builders weren't initially there, but instead have been added because
1920 they were required to reduce the load
<em>significantly
</em>. You need to understand
1921 that caches always come at a cost, even a runtime cache does! In particular,
1922 they will always consume memory that is not released over the duration of the
1923 request lifecycle and potentially even leak memory by holding references to
1924 objects and data structures that are no longer required.
</p>
1925 <p>Caching should always be a solution for a problem.
</p>
1926 <h3 id=
"when-to-use-a-cache">When to Use a Cache
<a class=
"headerlink" href=
"#when-to-use-a-cache" title=
"Permanent link">#
</a></h3>
1927 <p>It's difficult to provide a definite answer or checklist when to use a cache
1928 and why it is required at this point, because the answer is: It depends. The
1929 permission cache for user groups is a good example for a valid cache, where
1930 we can achieve significant performance improvement compared to processing this
1931 data on every request.
</p>
1932 <p>Its caches are build for each permutation of user group memberships that are
1933 encountered for a page request. Building this data is an expensive process that
1934 involves both inheritance and specific rules in regards to when a value for a
1935 permission overrules another value. The added benefit of this cache is that one
1936 cache usually serves a large number of users with the same group memberships and
1937 by computing these permissions once, we can serve many different requests. Also,
1938 the permissions are rather static values that change very rarely and thus we can
1939 expect a very high cache lifetime before it gets rebuild.
</p>
1940 <h3 id=
"when-not-to-use-a-cache">When not to Use a Cache
<a class=
"headerlink" href=
"#when-not-to-use-a-cache" title=
"Permanent link">#
</a></h3>
1941 <p>I remember, a few years ago, there was a plugin that displayed a user's character
1942 from an online video game. The character sheet not only included a list of basic
1943 statistics, but also displayed the items that this character was wearing and or
1944 holding at the time.
</p>
1945 <p>The data for these items were downloaded in bulk from the game's vendor servers
1946 and stored in a persistent cache file that periodically gets renewed. There is
1947 nothing wrong with the idea of caching the data on your own server rather than
1948 requesting them everytime from the vendor's servers - not only because they
1949 imposed a limit on the number of requests per hour.
</p>
1950 <p>Unfortunately, the character sheet had a sub-par performance and the users were
1951 upset by the significant loading times compared to literally every other page
1952 on the same server. The author of the plugin was working hard to resolve this
1953 issue and was evaluating all kind of methods to improve the page performance,
1954 including deep-diving into the realm of micro-optimizations to squeeze out every
1955 last bit of performance that is possible.
</p>
1956 <p>The real problem was the cache file itself, it turns out that it was holding the
1957 data for several thousand items with a total file size of about
13 megabytes.
1958 It doesn't look that much at first glance, after all this isn't the '
90s anymore,
1959 but unserializing a
13 megabyte array is really slow and looking up items in such
1960 a large array isn't exactly fast either.
</p>
1961 <p>The solution was rather simple, the data that was fetched from the vendor's API
1962 was instead written into a separate database table. Next, the persistent cache
1963 was removed and the character sheet would now request the item data for that
1964 specific character straight from the database. Previously, the character sheet
1965 took several seconds to load and after the change it was done in a fraction of
1966 a second. Although quite extreme, this illustrates a situation where the cache
1967 file was introduced in the design process, without evaluating if the cache -
1968 at least how it was implemented - was really necessary.
</p>
1969 <p>Caching should always be a solution for a problem. Not the other way around.
</p>
1975 <div class=
"md-source-date">
1978 Last update:
2021-
01-
08
1996 <footer class=
"md-footer">
1998 <nav class=
"md-footer__inner md-grid" aria-label=
"Footer">
2000 <a href=
"../../exceptions/" class=
"md-footer__link md-footer__link--prev" rel=
"prev">
2001 <div class=
"md-footer__button md-icon">
2002 <svg xmlns=
"http://www.w3.org/2000/svg" viewBox=
"0 0 24 24"><path d=
"M20 11v2H8l5.5 5.5-1.42 1.42L4.16 12l7.92-7.92L13.5 5.5 8 11h12z"/></svg>
2004 <div class=
"md-footer__title">
2005 <div class=
"md-ellipsis">
2006 <span class=
"md-footer__direction">
2015 <a href=
"../comments/" class=
"md-footer__link md-footer__link--next" rel=
"next">
2016 <div class=
"md-footer__title">
2017 <div class=
"md-ellipsis">
2018 <span class=
"md-footer__direction">
2024 <div class=
"md-footer__button md-icon">
2025 <svg xmlns=
"http://www.w3.org/2000/svg" viewBox=
"0 0 24 24"><path d=
"M4 11v2h12l-5.5 5.5 1.42 1.42L19.84 12l-7.92-7.92L10.5 5.5 16 11H4z"/></svg>
2031 <div class=
"md-footer-meta md-typeset">
2032 <div class=
"md-footer-meta__inner md-grid">
2033 <div class=
"md-footer-copyright">
2035 <div class=
"md-footer-copyright__highlight">
2036 Copyright ©
2020 WoltLab GmbH
2040 <a href=
"https://squidfunk.github.io/mkdocs-material/" target=
"_blank" rel=
"noopener">
2045 <div class=
"md-footer-copyright">
2046 <a href=
"https://www.woltlab.com/legal-notice/">Legal Notice
</a>
2047 <a href=
"https://www.woltlab.com/privacy-policy/">Privacy Policy
</a>
2054 <div class=
"md-dialog" data-md-component=
"dialog">
2055 <div class=
"md-dialog__inner md-typeset"></div>
2057 <script id=
"__config" type=
"application/json">{
"base":
"../../..",
"features": [],
"translations": {
"clipboard.copy":
"Copy to clipboard",
"clipboard.copied":
"Copied to clipboard",
"search.config.lang":
"en",
"search.config.pipeline":
"trimmer, stopWordFilter",
"search.config.separator":
"[\\s\\-]+",
"search.placeholder":
"Search",
"search.result.placeholder":
"Type to start searching",
"search.result.none":
"No matching documents",
"search.result.one":
"1 matching document",
"search.result.other":
"# matching documents",
"search.result.more.one":
"1 more on this page",
"search.result.more.other":
"# more on this page",
"search.result.term.missing":
"Missing"},
"search":
"../../../assets/javascripts/workers/search.fb4a9340.min.js",
"version": {
"provider":
"mike"}}
</script>
2060 <script src=
"../../../assets/javascripts/bundle.5cf3e710.min.js"></script>