-if ($usecache) {
- require Koha::Cache;
- Koha::Cache->import();
- $cache = Koha::Cache->new(
- {
- 'cache_type' => 'memcached',
- 'cache_servers' => $ENV{'MEMCACHED_SERVERS'}
- }
- );
- my $namespace = $ENV{'MEMCACHED_NAMESPACE'} || 'koha';
- my $page = $cache->get_from_cache("$namespace:intranet:report:$report");
+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");