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

NAME

Games::Lacuna::Task::Client - Client class

DESCRIPTION

Implements basic caching and the connection to the lacuna API.

ACCESSORS

client

Games::Lacuna::Client object

configdir

Games::Lacuna::Task config directory

storage

Access to the caching database via Games::Lacuna::Storage

config

Current config hash as read from the config file in configdir

stash

Simple Stash for storing various temporary values.

METHODS

task_config

 my $config = $client->task_config($task_name);

Calculates the config for a given task

empire_name

Returns the current empire name

get_cache

 my $value = $self->get_cache('key1');

Fetches a value from the cache. Returns undef if cache is not available or if it has expired.

clear_cache

 $self->clear_cache('key1');

Remove an entry from the cache.

set_cache

 $self->set_cache(
    max_age     => $valid_seconds,  # optional
    valid_until => $timestamp,      # optional, either max_age or valid_until
    key         => 'key1',          # required
    value       => $some_data       # required
 );

Stores an arbitrary data structure (no objects) in a persistent cache

request

Runs a request, caches the response and returns the response.

 my $response =  $self->request(
    object  => Games::Lacuna::Client::* object,
    method  => Method name,
    params  => [ Params ],
 );
 

paged_request

Fetches all response elements from a paged method

 my $response =  $self->paged_request(
    object  => Games::Lacuna::Client::* object,
    method  => Method name,
    params  => [ Params ],
    total   => 'field storing the total number of items',
    data    => 'field storing the items',
 );

build_object

 my $glc_object = $self->build_object('/university', id => $building_id);
 OR
 my $glc_object = $self->build_object($building_status_response);
 OR
 my $glc_object = $self->build_object('Spaceport', id => $building_id);
 OR
 my $glc_object = $self->build_object('Map');

Builds an <Games::Lacuna::Client::*> object

storage_do

 $self->storage_do('UPDATE .... WHERE id = ?',$id);

Runs a command in the cache database

storage_prepare

 my $sth = $self->storage_prepare('SELECT .... WHERE id = ?');

Prepares a SQL-query for the cache database and retuns the statement handle.