NAME

Zing::Savepoint - Lookup Table Savepoint

ABSTRACT

Lookup Table Savepoint Construct

SYNOPSIS

use Zing::Lookup;
use Zing::Savepoint;

my $lookup = Zing::Lookup->new(name => 'users');

$lookup->set('user-12345')->set(username => 'u12345');
$lookup->set('user-12346')->set(username => 'u12346');
$lookup->set('user-12347')->set(username => 'u12347');

my $savepoint = Zing::Savepoint->new(lookup => $lookup);

# $savepoint->test;

DESCRIPTION

This package provides a savepoint mechanism for saving and restoring large Zing::Lookup indices. If a lookup has an associated savepoint it will be used to build the index on (Zing::Lookup) object construction automatically, however, creating the savepoint (saving the state of the index) needs to be done manually.

LIBRARIES

This package uses type constraints from:

Zing::Types

ATTRIBUTES

This package has the following attributes:

lookup

lookup(Lookup)

This attribute is read-only, accepts (Lookup) values, and is required.

METHODS

This package implements the following methods:

capture

capture() : HashRef

The capture method returns the relevant state properties from the lookup.

capture example #1
# given: synopsis

$savepoint->capture;

drop

drop() : Bool

The drop method removes the persisted savepoint.

drop example #1
# given: synopsis

$savepoint->drop;

metadata

metadata() : HashRef

The metadata method returns the cached metadata property for the lookup.

metadata example #1
# given: synopsis

$savepoint->metadata;

name

name() : Str

The name method returns the generated savepoint name.

name example #1
# given: synopsis

$savepoint->name;

position

position() : Int

The position method returns the cached position property for the lookup.

position example #1
use Zing::Lookup;
use Zing::Savepoint;

my $lookup = Zing::Lookup->new(name => 'users');
my $savepoint = Zing::Savepoint->new(lookup => $lookup);

$lookup->drop;
$savepoint->drop;

$lookup->set('user-12345')->set(username => 'u12345');
$lookup->set('user-12346')->set(username => 'u12346');
$lookup->set('user-12347')->set(username => 'u12347');

$savepoint->send;
$savepoint->position;

recv

recv() : Any

The recv method returns the data (if any) associated with the savepoint.

recv example #1
# given: synopsis

$savepoint->recv;

repo

repo() : KeyVal

The repo method returns the Zing::KeyVal object used to manage the savepoint.

repo example #1
# given: synopsis

$savepoint->repo;

send

send() : HashRef

The send method caches and stores the data from "capture" as a savepoint and returns the data.

send example #1
# given: synopsis

$savepoint->send;

snapshot

snapshot() : HashRef

The snapshot method returns the cached snapshot property for the lookup.

snapshot example #1
# given: synopsis

$savepoint->snapshot;

test

test() : Bool

The test method checks whether the savepoint exists and returns truthy or falsy.

test example #1
# given: synopsis

$savepoint->repo->drop('state');

$savepoint->test;
test example #2
# given: synopsis

$savepoint->send;

$savepoint->test;

AUTHOR

Al Newkirk, awncorp@cpan.org

LICENSE

Copyright (C) 2011-2019, Al Newkirk, et al.

This is free software; you can redistribute it and/or modify it under the terms of the The Apache License, Version 2.0, as elucidated in the "license file".

PROJECT

Wiki

Project

Initiatives

Milestones

Contributing

Issues