| 2286 | | # If option provided, read from cache |
| 2287 | | my $cache_key = $arg->{key}; |
| 2288 | | my $ttl = $arg->{ttl} || 0; |
| 2289 | | if ($cache_key) { |
| 2290 | | require MT::Session; |
| 2291 | | my $terms = { id => $cache_key, kind => 'CO' }; |
| 2292 | | my $cache = $ttl ? MT::Session::get_unexpired_value($ttl, $terms) |
| 2293 | | : MT::Session->load($terms) |
| 2294 | | ; |
| 2295 | | if ($cache) { |
| 2296 | | return $cache->data() if !$use_ssi; |
| 2297 | | |
| 2298 | | my $include_name = $cache_key || $tmpl_name; |
| | 2286 | # Try to read from cache |
| | 2287 | my $cache_enabled = $blog && $blog->include_cache |
| | 2288 | && ($arg->{cache} || $arg->{key} || (exists $arg->{ttl})) ? 1 : 0; |
| | 2289 | my $cache_key = $arg->{key} ? $arg->{key} |
| | 2290 | : 'blog::' . $blog_id . '::template_' . $type . '::' . $tmpl_name; |
| | 2291 | my $ttl = exists $arg->{ttl} ? $arg->{ttl} : 60 * 60; # default 60 min. |
| | 2292 | my $cache_driver; |
| | 2293 | if ($cache_enabled) { |
| | 2294 | require MT::Cache::Negotiate; |
| | 2295 | $cache_driver = MT::Cache::Negotiate->new( ttl => $ttl ); |
| | 2296 | my $cache_value = $cache_driver->get($cache_key); |
| | 2297 | |
| | 2298 | if ($cache_value) { |
| | 2299 | return $cache_value if !$use_ssi; |
| | 2300 | |
| | 2301 | my $include_name = $arg->{key} || $tmpl_name; |