- $r = q("SELECT `event`.*, `event`.`id` AS `eid`, `contact`.* FROM `event`
- INNER JOIN `contact` ON `contact`.`id` = `event`.`cid`
- WHERE `event`.`uid` = %d AND `type` = 'birthday' AND `start` < '%s' AND `finish` > '%s'
- ORDER BY `start` ASC ",
- intval(local_user()),
- dbesc(datetime_convert('UTC','UTC','now + 6 days')),
- dbesc(datetime_convert('UTC','UTC','now'))
- );
-
- if($r && count($r)) {
+ $cachekey = "get_birthdays:".local_user();
+ $r = Cache::get($cachekey);
+ if (is_null($r)) {
+ $r = q("SELECT `event`.*, `event`.`id` AS `eid`, `contact`.* FROM `event`
+ INNER JOIN `contact` ON `contact`.`id` = `event`.`cid`
+ WHERE `event`.`uid` = %d AND `type` = 'birthday' AND `start` < '%s' AND `finish` > '%s'
+ ORDER BY `start` ASC ",
+ intval(local_user()),
+ dbesc(datetime_convert('UTC','UTC','now + 6 days')),
+ dbesc(datetime_convert('UTC','UTC','now'))
+ );
+ if (dbm::is_result($r)) {
+ Cache::set($cachekey, $r, CACHE_HOUR);
+ }
+ }
+ if (dbm::is_result($r)) {