-if (Koha::Cache->is_cache_active) {
- if ($report_name) { # When retrieving by name, we have to hit the
- # database to get the ID before we can check
- # the cache. Yuck.
- ( $sql, $type, $report_name, $notes, $cache_expiry, $public, $report_id ) =
- get_saved_report( { 'name' => $report_name } );
- }
-
- $cache = Koha::Cache->new();
- my $page = $cache->get_from_cache("intranet:report:$report_id");
- if ($page) {
- print $query->header;
- print $page;
- exit;
- }
+my $cache = Koha::Caches->get_instance();
+my $cache_active = $cache->is_cache_active;
+my ($cache_key, $json_text);
+if ($cache_active) {
+ $cache_key = "intranet:report:".($report_name ? "report_name:$report_name:" : "id:$report_id:")
+ . join( '-', @sql_params );
+ $json_text = $cache->get_from_cache($cache_key);