Skip to content

Commit 3bfb6b1

Browse files
perf: allow Model classes to be marked as ModelCache exempt
1 parent a45a75a commit 3bfb6b1

File tree

1 file changed

+8
-1
lines changed
  • pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Core

1 file changed

+8
-1
lines changed

pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Core/Model.inc

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,13 @@ class Model {
144144
*/
145145
public Cache|null $cache = null;
146146

147+
/**
148+
* @var bool $model_cache_exempt
149+
* If set to `true`, this Model will be exempt from any global Model caching mechanisms. This is primarily
150+
* used for Models that frequently change or are not suitable for caching.
151+
*/
152+
public bool $model_cache_exempt = false;
153+
147154
/**
148155
* @var ModelSet $related_objects
149156
* A ModelSet containing foreign Model objects related to this Model. These are primarily populated by
@@ -1943,7 +1950,7 @@ class Model {
19431950
$model = new $model_name();
19441951
$model_objects = [];
19451952
$requests_pagination = ($limit or $offset);
1946-
$cache_exempt = ($requests_pagination or $reverse or $model->internal_callable);
1953+
$cache_exempt = ($requests_pagination or $reverse or $model->model_cache_exempt);
19471954

19481955
# Throw an error if pagination was requested on a Model without $many enabled
19491956
if (!$model->many and $requests_pagination) {

0 commit comments

Comments
 (0)