Skip to content
This repository has been archived by the owner on Oct 24, 2018. It is now read-only.

Commit

Permalink
Merge pull request #7 from jonasva/jonasva-patch-date-based-cache
Browse files Browse the repository at this point in the history
Determine cache name based on formatted date
  • Loading branch information
freekmurze committed Mar 13, 2015
2 parents aabec11 + ff6f51b commit 69036c0
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/AnalyticsReports.php
Original file line number Diff line number Diff line change
Expand Up @@ -260,12 +260,14 @@ public function getSiteIdByUrl($url)
*/
public function performQuery($startDate, $endDate, $metrics, $others = array())
{
$cacheName = $this->determineCacheName(func_get_args());
$startDate = $startDate->format('Y-m-d');
$endDate = $endDate->format('Y-m-d');
$cacheName = $this->determineCacheName(array($startDate, $endDate, $metrics, $others));

if ($this->useCache() AND Cache::has($cacheName)) {
$answer = Cache::get($cacheName);
} else {
$answer = $this->client->query($this->siteId, $startDate->format('Y-m-d'), $endDate->format('Y-m-d'), $metrics, $others);
$answer = $this->client->query($this->siteId, $startDate, $endDate, $metrics, $others);
if ($this->useCache()) {
Cache::put($cacheName, $answer, $this->cacheLifeTimeInMinutes);
}
Expand Down

0 comments on commit 69036c0

Please sign in to comment.