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

NAME

Bot::BasicBot::Pluggable::Store - base class for the back-end pluggable store

SYNOPSIS

  my $store = Bot::BasicBot::Pluggable::Store->new( option => "value" );

  my $namespace = "MyModule";

  for ( $store->keys($namespace) ) {
    my $value = $store->get($namespace, $_);
    $store->set( $namespace, $_, "$value and your momma." );
  }

Store classes should subclass this and provide some persistent way of storing things.

METHODS

new()

Standard new method, blesses a hash into the right class and puts any key/value pairs passed to it into the blessed hash. Calls load() to load any internal variables, then init, which you can also override in your module.

init()

Called as part of new class construction, before load().

load()

Called as part of new class construction, after init().

save()

Subclass me. But, only if you want to. See ...Store::Storable.pm as an example.

keys($namespace,[$regex])

Returns a list of all store keys for the passed $namespace.

If you pass $regex then it will only pass the keys matching $regex

get($namespace, $variable)

Returns the stored value of the $variable from $namespace.

set($namespace, $variable, $value)

Sets stored value for $variable to $value in $namespace. Returns store object.

unset($namespace, $variable)

Removes the $variable from the store. Returns store object.

namespaces()

Returns a list of all namespaces in the store.

dump()

Dumps the complete store to a huge Storable scalar. This is mostly so you can convert from one store to another easily, i.e.:

  my $from = Bot::BasicBot::Pluggable::Store::Storable->new();
  my $to   = Bot::BasicBot::Pluggable::Store::DBI->new( ... );
  $to->restore( $from->dump );

dump is written generally so you don't have to re-implement it in subclasses.

restore($data)

Restores the store from a dump().

AUTHOR

Tom Insam <tom@jerakeen.org>

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

SEE ALSO

Bot::BasicBot::Pluggable

Bot::BasicBot::Pluggable::Module