The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

LWP::UserAgent::SemWebCache - LWP::UserAgent for caching SPARQL Queries

SYNOPSIS

This is a slight modification of LWP::UserAgent::CHICaching, and can be used much like it:

  my $cache = CHI->new( driver => 'Memory', global => 1 );
  my $ua = LWP::UserAgent::SemWebCache->new(cache => $cache);
  my $res1 = $ua->get("http://localhost:3000/?query=DAHUT");

DESCRIPTION

This class composes the two roles LWP::UserAgent::Role::CHICaching and LWP::UserAgent::Role::CHICaching::VaryNotAsterisk and reimplements the key attribute.

For now, it makes a relatively uncertain assumption that could in some cases violate Section 4.1 of RFC7234 and cause unpredictable results: Since SPARQL results come in different serializations, the Vary header will be present in most cases, and therefore, different caches would usually have been required. However, if we assume that no variations that are semantically significant could occur, then we should be OK. Unless, of course, the server declared that anything goes, which amount to setting Vary: *, in that case, we don't cache.

Additionally, since the URI resulting from a SPARQL protocol query might be long, and long keys are often difficult for backend caches, so the reimplementation of key will create a digest.

Attributes and Methods

key, clear_key

The key to use for a response. This role will return the canonical URI of the request as a string, which is a reasonable default.

AUTHOR

Kjetil Kjernsmo <kjetilk@cpan.org>.

COPYRIGHT AND LICENCE

This software is copyright (c) 2015, 2016 by Kjetil Kjernsmo.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.