- // Fetch data from cache
- $cache = CRM_Core_DAO::executeQuery("SELECT data, created_date FROM civicrm_cache
- WHERE group_name = 'dashboard' AND path = 'newsfeed'");
- if ($cache->fetch()) {
- $expire = time() - (60 * 60 * 24 * self::CACHE_DAYS);
- // Refresh data after CACHE_DAYS
- if (strtotime($cache->created_date) < $expire) {
- $new_data = $this->getFeeds();
- // If fetching the new rss feed was successful, return it
- // Otherwise use the old cached data - it's better than nothing
- if ($new_data) {
- return $new_data;
- }
+ $value = Civi::cache('community_messages')->get('dashboard_newsfeed');
+
+ if (!$value) {
+ $value = $this->getFeeds();
+
+ if ($value) {
+ Civi::cache('community_messages')->set('dashboard_newsfeed', $value, (60 * 60 * 24 * self::CACHE_DAYS));