This commit is contained in:
2026-04-01 20:15:45 +02:00
parent 92b7a2a95e
commit 9b36f8fec3
35 changed files with 2371 additions and 31 deletions

View File

@@ -153,6 +153,26 @@ class Carei_Softra_API {
return $this->request( 'GET', '/branch/list' );
}
/**
* Get branches with 60-min transient cache.
*/
public function get_branches_cached() {
$cache_key = 'carei_branches_list';
$cached = get_transient( $cache_key );
if ( false !== $cached ) {
return $cached;
}
$branches = $this->get_branches();
if ( is_wp_error( $branches ) || ! is_array( $branches ) ) {
return is_wp_error( $branches ) ? $branches : array();
}
set_transient( $cache_key, $branches, HOUR_IN_SECONDS );
return $branches;
}
public function get_all_car_classes() {
return $this->request( 'GET', '/car/class/listAll' );
}
@@ -170,7 +190,7 @@ class Carei_Softra_API {
return $cached;
}
$branches = $this->get_branches();
$branches = $this->get_branches_cached();
if ( is_wp_error( $branches ) || ! is_array( $branches ) ) {
return is_wp_error( $branches ) ? $branches : array();
}