Skip to content

Commit

Permalink
fix: allow setting cache expiry
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronflorey committed Jan 17, 2025
1 parent 3424f83 commit 631a09e
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/Support/AbstractRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ abstract class AbstractRequest extends Request implements Cacheable, HasBody
/** @var null|class-string<T> */
protected ?string $responseModel = null;

private $cacheExpiryInSeconds = 60 * 15;

public function __construct(protected XeroPracticeManagerConnector $connector)
{
if (!config('xero-practice-manager.cache')) {
Expand All @@ -49,7 +51,15 @@ public function resolveCacheDriver(): Driver

public function cacheExpiryInSeconds(): int
{
return 60 * 15;
return $this->cacheExpiryInSeconds;
}

public function enableCaching(int $cacheExpiryInSeconds): static
{
$this->cacheExpiryInSeconds = $cacheExpiryInSeconds;
$this->cachingEnabled = true;

return $this;
}

protected function xmlResponse(array $payload, string $root)
Expand Down

0 comments on commit 631a09e

Please sign in to comment.