NAME
    Wikibase::Cache::Backend - Abstract class for Wikibase::Cache backend.

SYNOPSIS
     use Wikibase::Cache::Backend;

     my $obj = Wikibase::Cache::Backend->new;
     my $value = $obj->get($type, $key);
     my $saved_value = $obj->save($type, $key, $value);

DESCRIPTION
    Abstract class for Wikibase::Cache backend. Methods, which needs to
    implement are: "_get()" and "_save()".

METHODS
  "new"
     my $obj = Wikibase::Cache::Backend->new;

    Constructor.

    Returns instance of object.

  "get"
     my $value = $obj->get($type, $key);

    Get cache value for $type and $key. Possible types are 'description' and
    'label'.

    Returns string.

  "save"
     my $saved_value = $obj->save($type, $key, $value);

    Save cache value for $type and $key. Value will be set to $value.
    Possible types are 'description' and 'label'.

    Returns string.

ERRORS
     new():
             From Class::Utils::set_params():
                     Unknown parameter '%s'.

     get():
             This is abstract class. You need to implement '_get' method.
             Type '%s' isn't supported.
             Type must be defined.';

     save():
             This is abstract class. You need to implement '_save' method.
             Type '%s' isn't supported.
             Type must be defined.';

EXAMPLE
     use strict;
     use warnings;

     package Foo;

     use base qw(Wikibase::Cache::Backend);

     sub _get {
             my ($self, $type, $key) = @_;

             my $value = $self->{'_data'}->{$type}->{$key} || undef;

             return $value;
     }

     sub _save {
             my ($self, $type, $key, $value) = @_;

             $self->{'_data'}->{$type}->{$key} = $value;

             return $value;
     }

     package main;

     # Object.
     my $obj = Foo->new;

     # Save cached value.
     $obj->save('label', 'foo', 'FOO');

     # Get cached value.
     my $value = $obj->get('label', 'foo');

     # Print out.
     print $value."\n";

     # Output like:
     # FOO

DEPENDENCIES
    Class::Utils, Error::Pure, List::Util, Readonly.

SEE ALSO
    Wikibase::Cache
        Wikibase cache class.

REPOSITORY
    <https://github.com/michal-josef-spacek/Wikibase-Cache-Backend>

AUTHOR
    Michal Josef Špaček <mailto:skim@cpan.org>

    <http://skim.cz>

LICENSE AND COPYRIGHT
    © 2021-2023 Michal Josef Špaček

    BSD 2-Clause License

VERSION
    0.04

