- Add Redis mget method and cache management improvements
- Update cache expiration times for `economicCustomerName` and `isBooked` objects - Introduce `getCachedForMultipleObjects` for batch cache retrieval - Optimize `isBooked` with optional caching and update to store results - Implement `getCustomerNames` in `users_o` with caching for bulk name retrieval - Refactor customer transaction handling in `InvoicingPeriodRoute` for efficiency - Filter orders excluded from invoicing in `collected_order_invoices_o`
This commit is contained in:
@@ -759,16 +759,29 @@ class orders_o extends db
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
public function isBooked(): bool
|
||||
public function isBooked(bool $useCache = false): bool
|
||||
{
|
||||
$this->requireSelected();
|
||||
// Check if we should use the cached value
|
||||
if ($useCache) {
|
||||
$cached = self::getCached('isBooked', $this->id);
|
||||
if ($cached !== null) {
|
||||
return (bool)$cached;
|
||||
}
|
||||
}
|
||||
// Check the invoice collection has been booked
|
||||
if ((int)$this->invoice_collection_id->value() > 0) {
|
||||
$invoice_collection = (new collected_order_invoices_o())->select((int)$this->invoice_collection_id->value());
|
||||
self::requireSelected();
|
||||
return $invoice_collection->isBooked();
|
||||
$isBooked = $invoice_collection->isBooked();
|
||||
// Cache the result
|
||||
self::cache('isBooked', $isBooked, $this->id);
|
||||
self::setCachedExpiration('isBooked', self::$isBookedCacheExpiration, $this->id);
|
||||
return $isBooked;
|
||||
} else {
|
||||
// If there is no invoice collection, the order is not booked
|
||||
self::cache('isBooked', false, $this->id);
|
||||
self::setCachedExpiration('isBooked', self::$isBookedCacheExpiration, $this->id);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user