CDB-TinyCDB-Wrapper

 view release on metacpan or  search on metacpan

lib/CDB/TinyCDB/Wrapper.pm  view on Meta::CPAN

  return exists $self->{modified}->{$key} ? $self->{modified}->{$key} : $self->{cdb}->get ($key);
}

=head2 keys

Retrieves the list of keys from the DB.

=cut

sub keys {
  my ($self) = @_;
  # Hold our list of keys
  my %keys;
  # Get the keys on disk
  map {$keys{$_}++} $self->{cdb}->keys;
  # Iterate over the keys in memory
  for my $key (CORE::keys %{$self->{modified}}) {
    # If the key has a value in memory, make sure it's includee
    if (defined $self->{modified}->{$key}) {
      $keys{$key}++
    } else {
      # This has been deleted in memory, delete from list of keys
      delete $keys{$key};
    }
  }
  return CORE::keys %keys;
}

=head2 set

Sets the specified key to the specified value in the DB.

=cut

sub set {
  my ($self, $key, $value) = @_;
  $self->{modified}->{$key} = $value;
}

=head2 DESTROY

Called when the object is deleted or goes out of scope, it closes the
file.  This is just here for compatibility with versions < 0.3---all
new development should explicitly call close, or risk potential issues
if the data doesn't get GC'd immediately.

=cut

sub DESTROY {
  my ($self) = @_;
  $self->close if ($self->{cdb});
}

=head1 AUTHOR

Michael Alan Dorman, C<< <mdorman at ironicdesign.com> >>

=head1 BUGS

Please report any bugs or feature requests to
C<bug-cdb-tinycdb-overlay at rt.cpan.org>, or through the web
interface at
L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=CDB-TinyCDB-Wrapper>.
I will be notified, and then you'll automatically be notified of
progress on your bug as I make changes.

=head1 SUPPORT

You can find documentation for this module with the perldoc command.

    perldoc CDB::TinyCDB::Wrapper

You can also look for information at:

=over 4

=item * RT: CPAN's request tracker

L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=CDB-TinyCDB-Wrapper>

=item * AnnoCPAN: Annotated CPAN documentation

L<http://annocpan.org/dist/CDB-TinyCDB-Wrapper>

=item * CPAN Ratings

L<http://cpanratings.perl.org/d/CDB-TinyCDB-Wrapper>

=item * Search CPAN

L<http://search.cpan.org/dist/CDB-TinyCDB-Wrapper/>

=back

=head1 ACKNOWLEDGEMENTS

CDB::TinyCDB, without which this module would have no reason to exist

=head1 LICENSE AND COPYRIGHT

Copyright 2010 Michael Alan Dorman.

This program is free software; you can redistribute it and/or modify it
under the terms of either: the GNU General Public License as published
by the Free Software Foundation; or the Artistic License.

See http://dev.perl.org/licenses/ for more information.

=cut

1;                              # End of CDB::TinyCDB::Wrapper



( run in 2.076 seconds using v1.01-cache-2.11-cpan-600a1bdf6e4 )