| Bot-BasicBot-Pluggable documentation | Contained in the Bot-BasicBot-Pluggable distribution. |
Bot::BasicBot::Pluggable::Store::Deep - use DBM::Deep to provide a storage backend
version 0.93
my $store = Bot::BasicBot::Pluggable::Store::Deep->new(
file => "filename"
);
$store->set( "namespace", "key", "value" );
This is a Bot::BasicBot::Pluggable::Store that uses DBM::Deep to store
the values set by modules.
Simon Wistow <simon@thegestalt.org>
Copyright 2005, Simon Wistow
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
| Bot-BasicBot-Pluggable documentation | Contained in the Bot-BasicBot-Pluggable distribution. |
package Bot::BasicBot::Pluggable::Store::Deep; BEGIN { $Bot::BasicBot::Pluggable::Store::Deep::VERSION = '0.93'; } use warnings; use strict; use DBM::Deep; use base qw( Bot::BasicBot::Pluggable::Store ); sub init { my $self = shift; delete $self->{type}; $self->{file} ||= 'bot-basicbot.deep'; $self->{_db} = DBM::Deep->new(%$self) || die "Couldn't connect to DB '$self->{file}'"; } sub set { my ( $self, $namespace, $key, $value ) = @_; $self->{_db}->{$namespace}->{$key} = $value; return $self; } sub get { my ( $self, $namespace, $key ) = @_; return $self->{_db}->{$namespace}->{$key}; } sub unset { my ( $self, $namespace, $key ) = @_; delete $self->{_db}->{$namespace}->{$key}; } sub keys { my ( $self, $namespace, %opts ) = @_; # no idea why this works return CORE::keys %{ $self->{_db}->{$namespace} } unless exists $opts{res} && @{ $opts{res} }; my $mod = $self->{_db}->{$namespace} || {}; return $self->_keys_aux( $mod, $namespace, %opts ); } sub namespaces { my ($self) = @_; return CORE::keys %{ $self->{_db} }; } 1; __END__