RDF::Trine::Store::Tardis - time travelling triple store

     use DateTime;
     use RDF::Trine qw[iri statement];
     use RDF::Trine::Store::Tardis;
     my $S = iri('');
     my $P = iri('');
     my $O = iri('');
     my $store = RDF::Trine::Store::Tardis->new;
     $store->add(statement($S, $P, $O));
     sleep 5;
     $store->remove(statement($S, $P, $O));
     sleep 1;
     my $then     = DateTime->now->subtract(seconds => 3);
     my $then_iri = $store->tardis_make_iri($then);
     my $results  = $store->get_statements(undef, undef, undef, $then_iri);
     while (my $result = $results->next)
       print $result->as_string . "\n";

    Tempus is a triple store (not a quad store!) that keeps track of when
    triples were added and removed from the graph.

        Constructs a temporary store.

    "new($name, $dbh)"
        Uses an existing DBI database connection.

    "new($name, $dsn, $username, $password)"
        Opens a DBI database connection using supplied DSN, username and

    Note that while it's not especially feasible to share the same database
    and model name between Tardis and RDF::Trine::Store::DBI, the latter
    should be able to safely *read* a Tardis store.

    Tempus inherits from RDF::Trine::Store so provides all the methods of an
    RDF::Trine::Store. The following additional methods and differences are

    "remove_statements($subj, $pred, $obj)"
        Can only be handle a triple, not a quad. If passed a quad, a warning
        is given and the context is ignored.

    "get_statements($subj, $pred, $obj)"
        Ignores historic and futuristic triples, only returning triples that
        are valid at the current time.

    "get_statements($subj, $pred, $obj, $context)"
        $context must be an IRI if the form <tempus:2003-02-01T12:00:00Z> or
        a DateTime object. Returns triples valid at that time.

    "get_statements($subj, $pred, $obj, undef)"
        Returns current, historic and future triples.

    "tardis_add_statement($triple, $datetime)"
    "tardis_remove_statement($triple, $datetime)"
        Add or remove a statement at a time other than now. $datetime can be
        a special tempus URI, or a "DateTime" object.

        Quads are supported for these methods, provided that the context is
        a special tempus URI.

        Given a "DateTime" object, returns an RDF::Trine::Node::Resource for
        a special tempus URI representing that time.

        Does the inverse of "tardis_make_iri".

  Tempus URIs
    Here is the EBNF notation for tempus URIs:

     tempusURI = 'tempus:', ('now' | date | dateTime);
     dateTime  = date, 'T', time;
     date      = year, '-', month, '-', day;
     time      = hour, ':', minute, [':', second,] [timezone];
     year      = digit, digit, digit, digit;
     month     = digit, digit;
     day       = digit, digit;
     hour      = digit, digit;
     minute    = digit, digit;
     second    = digit, digit;
     timezone  = 'Z' | numTZ
     numTZ     = ( '+' | '-' ), digit, digit, digit, digit;
     digit     = '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9';

    I imagine there are many.

    Please report any bugs to <>.

    RDF::Trine, DateTime.

    RDF::Trine::Store::Tardis::SQLite, RDF::Trine::Store::Tardis::mysql,



    Toby Inkster <>.

    Copyright 2011 Toby Inkster

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