- 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:
Jeppe Bundgaard
2025-11-26 10:01:24 +01:00
parent 7e9c456074
commit ecd44a455a
6 changed files with 168 additions and 54 deletions
+15 -2
View File
@@ -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;
}
}