*/
protected $allSites = null;
+ /**
+ * @var int
+ */
+ protected $cacheDuration = 300;
+
public function __construct(
$baseUrl,
$token,
$this->client = new Client(['base_uri' => $this->serverUrl]);
}
+ /**
+ * @return int
+ */
+ public function getCacheDuration(): int {
+ return $this->cacheDuration;
+ }
+
+ /**
+ * @param int $cacheDuration
+ */
+ public function setCacheDuration(int $cacheDuration): void {
+ $this->cacheDuration = max(1, $cacheDuration);
+ }
+
/**
* Get API token
*
$defaultOptions = ['query' => array_merge($default, $params)];
$options = array_merge($defaultOptions, $options);
$cacheKey = 'matomo_api_call' . hash('sha256', print_r($options, true));
- return Cache::remember($cacheKey, 300, function () use ($options, $method) {
+ return Cache::remember($cacheKey, $this->getCacheDuration(), function () use ($options, $method) {
try {
$response = $this->client->get('/', $options);
} catch (RequestException $e) {