internal package
Foswiki::Contrib::CacheContrib Interface to the caching services. This consists of two parts:
Both of these requirements happen so often in Foswiki plugins that they have been provided as a basic service to be accessed by third party plugins. For instance, ImagePlugin caches image geometries as analysing and extracting this information from pictures can be quite expensive. NumberPlugin fetches exchange rates of currencies from an external provider and caches them locally. FeedPlugin fetches RSS and Atom feeds and caches them locally when rerendering them on a Foswiki page. SolrPlugin serializes binary document formats while indexing their content with interim results cached locally to speed up reindexing those documents.
namespace
(defaults to "UserAgent") parameter defines the cache section used for this agent.
my $cache = Foswiki::Contrib::CacheContrib::getCache("ImagePlugin");
Foswiki::Func::getExternalResource()
with just adding caching.
It basically is compatible with LWP::UserAgent::get
.
Usage:
my $response = Foswiki::Contrib::CacheContrib::getExternalResource($url); throw Error::Simple("http error fetching $url: ".$response->code." - ".$response->status_line) unless $response->is_success; my $content = $response->decoded_content();
clears the cache for the given namespace
purges expired entries of the cache for the given namespace