Skip to content
This repository was archived by the owner on Feb 18, 2019. It is now read-only.

Commit 78eab7c

Browse files
authored
Merge pull request #7 from TBlindaruk/new_cache_for_each_week
[CACHE] Used different cache for first and second week.
2 parents df8ba9c + 01ed21d commit 78eab7c

3 files changed

Lines changed: 190 additions & 4 deletions

File tree

WhereIsMyTeacherBot/Service/TeacherService.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
namespace WhereIsMyTeacherBot\Service;
55

6+
use Carbon\Carbon;
67
use Symfony\Component\Cache\Simple\FilesystemCache;
78
use WhereIsMyTeacherBot\Model\TeacherParser;
89

@@ -30,7 +31,8 @@ public function __construct()
3031
*/
3132
public function getSchedule(string $teacherName)
3233
{
33-
$cacheKey = md5($teacherName);
34+
$week = Carbon::now()->weekOfYear % 2;
35+
$cacheKey = md5($teacherName . $week);
3436

3537
if ($this->cache->has($cacheKey)) {
3638
return $this->cache->get($cacheKey);

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
"php": "^7.0",
1212
"longman/telegram-bot": "^0.44.1",
1313
"electrolinux/phpquery": "^0.9.6",
14-
"symfony/cache": "^4.1"
14+
"symfony/cache": "^4.1",
15+
"nesbot/carbon": "^1.32"
1516
},
1617
"require-dev": {
1718
}

composer.lock

Lines changed: 185 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)