Cache integration API reads and refresh them on a schedule
Deploy HickLab3D Dashboard / Deploy to production (push) Successful in 28s
Deploy HickLab3D Dashboard / Deploy to production (push) Successful in 28s
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5.5
parent
8bee8d42c7
commit
2fe4fbd91e
@@ -8,7 +8,7 @@ use Throwable;
|
||||
|
||||
class Bambuddy
|
||||
{
|
||||
public function __construct(private IntegrationSettings $settings) {}
|
||||
public function __construct(private IntegrationSettings $settings, private IntegrationCache $cache) {}
|
||||
|
||||
public function url(): string
|
||||
{
|
||||
@@ -26,6 +26,11 @@ class Bambuddy
|
||||
throw new RuntimeException('BamBuddy API key is not configured.');
|
||||
}
|
||||
|
||||
return $this->cache->remember('bambuddy.printers.'.md5($this->url()), 45, fn (): array => $this->fetchPrinters());
|
||||
}
|
||||
|
||||
private function fetchPrinters(): array
|
||||
{
|
||||
$url = rtrim($this->url(), '/').'/api/v1/printers';
|
||||
$apiKey = $this->settings->for('bambuddy')['api_key'];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user