|
Lines 25-51
use C4::Reports::Guided;
Link Here
|
| 25 |
use JSON; |
25 |
use JSON; |
| 26 |
use CGI; |
26 |
use CGI; |
| 27 |
|
27 |
|
|
|
28 |
use Koha::Cache; |
| 29 |
|
| 28 |
my $query = CGI->new(); |
30 |
my $query = CGI->new(); |
| 29 |
my $report = $query->param('id'); |
31 |
my $report = $query->param('id'); |
| 30 |
|
32 |
|
| 31 |
my $cache; |
33 |
my $cache; |
| 32 |
my $usecache = C4::Context->ismemcached; |
|
|
| 33 |
|
34 |
|
| 34 |
my ( $sql, $type, $name, $notes, $cache_expiry, $public ) = |
35 |
my ( $sql, $type, $name, $notes, $cache_expiry, $public ) = |
| 35 |
get_saved_report($report); |
36 |
get_saved_report($report); |
| 36 |
die "Sorry this report is not public\n" unless $public; |
37 |
die "Sorry this report is not public\n" unless $public; |
| 37 |
|
38 |
|
| 38 |
if ($usecache) { |
39 |
if (Koha::Cache->is_cache_active) { |
| 39 |
require Koha::Cache; |
|
|
| 40 |
Koha::Cache->import(); |
| 41 |
$cache = Koha::Cache->new( |
40 |
$cache = Koha::Cache->new( |
| 42 |
{ |
|
|
| 43 |
'cache_type' => 'memcached', |
| 44 |
'cache_servers' => $ENV{'MEMCACHED_SERVERS'} |
| 45 |
} |
| 46 |
); |
41 |
); |
| 47 |
my $namespace = $ENV{'MEMCACHED_NAMESPACE'} || 'koha'; |
42 |
my $page = $cache->get_from_cache("opac:report:$report"); |
| 48 |
my $page = $cache->get_from_cache("$namespace:opac:report:$report"); |
|
|
| 49 |
if ($page) { |
43 |
if ($page) { |
| 50 |
print $query->header; |
44 |
print $query->header; |
| 51 |
print $page; |
45 |
print $page; |
|
Lines 61-68
my $lines = $sth->fetchall_arrayref;
Link Here
|
| 61 |
my $json_text = to_json($lines); |
55 |
my $json_text = to_json($lines); |
| 62 |
print $json_text; |
56 |
print $json_text; |
| 63 |
|
57 |
|
| 64 |
if ($usecache) { |
58 |
if (Koha::Cache->is_cache_active) { |
| 65 |
my $namespace = $ENV{'MEMCACHED_NAMESPACE'} || 'koha'; |
59 |
$cache->set_in_cache( "opac:report:$report", $json_text, $cache_expiry ); |
| 66 |
$cache->set_in_cache( "$namespace:opac:report:$report", |
|
|
| 67 |
$json_text, $cache_expiry ); |
| 68 |
} |
60 |
} |