@@ -96,3 +96,50 @@ the value defined in **app/Config/Constants.php**.
96
96
97
97
.. note :: If the same namespace is defined in both CodeIgniter and Composer, CodeIgniter's autoloader will be
98
98
the first one to get a chance to locate the file.
99
+
100
+ .. _file-locator-caching :
101
+
102
+ FileLocator Caching
103
+ *******************
104
+
105
+ .. versionadded :: 4.5.0
106
+
107
+ **FileLocator ** is responsible for finding files or getting a classname from a file,
108
+ which cannot be achieved with PHP autoloading.
109
+
110
+ To improve its performance, FileLocator Caching has been implemented.
111
+
112
+ How It Works
113
+ ============
114
+
115
+ - Save the all found data by FileLocator into a cache file when destructing,
116
+ if the cache data is updated.
117
+ - Restore cached data when instantiating if cached data is available.
118
+
119
+ The cached data are used permanently.
120
+
121
+ How to Delete Cached Data
122
+ =========================
123
+
124
+ Once stored, the cached data never expire.
125
+
126
+ So if you add or remove files or change existing file paths, or namespaces, old
127
+ cached data will be returned and your app may not work properly.
128
+
129
+ In that case, you must manually delete the cache file. If you add a CodeIgniter
130
+ package via Composer, you also need to delete the cache file.
131
+
132
+ You can use the ``spark cache:clear `` command:
133
+
134
+ .. code-block :: console
135
+
136
+ php spark cache:clear
137
+
138
+ Or simply delete the **writable/cache/FileLocatorCache ** file.
139
+
140
+ How to Enable FileLocator Caching
141
+ =================================
142
+
143
+ Add the following code in **app/Config/Services.php **:
144
+
145
+ .. literalinclude :: autoloader/004.php
0 commit comments