update
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user