Skip to content

Commit 2beb842

Browse files
fix: do not cache models with internal callables by default
This commit ensures that Model's with internal_callables are not cached by default. This is primarily because these Models often fetch real-time data, not stored config data. This change also allows for these models to override this default.
1 parent 62ca4fe commit 2beb842

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

  • pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Core

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ class Model {
149149
* If set to `true`, this Model will be exempt from any global Model caching mechanisms. This is primarily
150150
* used for Models that frequently change or are not suitable for caching.
151151
*/
152-
public bool $model_cache_exempt = false;
152+
public bool $model_cache_exempt;
153153

154154
/**
155155
* @var ModelSet $related_objects
@@ -341,6 +341,11 @@ class Model {
341341
);
342342
}
343343

344+
# Set the model cache exemption if it was not explicitly defined
345+
if (!isset($this->model_cache_exempt)) {
346+
$this->model_cache_exempt = (bool) $this->internal_callable;
347+
}
348+
344349
# Check for known $options and map them to their Model properties
345350
$options = $this->set_construct_options($options);
346351

0 commit comments

Comments
 (0)