Bug 7955 follow-up spelling fixes
[koha.git] / svc / report
index 476475c..18e1986 100755 (executable)
@@ -26,11 +26,13 @@ use C4::Reports::Guided;
 use JSON;
 use CGI;
 
+use Koha::Cache;
+
+
 my $query  = CGI->new();
 my $report = $query->param('id');
 
 my $cache;
-my $usecache = C4::Context->ismemcached;
 
 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
     {
@@ -42,17 +44,9 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
     }
 );
 
-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) {
+    $cache = Koha::Cache->new();
+    my $page = $cache->get_from_cache("intranet:report:$report");
     if ($page) {
         print $query->header;
         print $page;
@@ -72,8 +66,6 @@ my $lines     = $sth->fetchall_arrayref;
 my $json_text = to_json($lines);
 print $json_text;
 
-if ($usecache) {
-    my $namespace = $ENV{'MEMCACHED_NAMESPACE'} || 'koha';
-    $cache->set_in_cache( "$namespace:intranet:report:$report",
-        $json_text, $cache_expiry );
+if (Koha::Cache->is_cache_active) {
+    $cache->set_in_cache( "intranet:report:$report", $json_text, $cache_expiry );
 }