22 November 2012
I have been playing with Net::Amazon::DynamoDB a lot recently. this article is not to comment on that service. it's just a few notes for Perl guys who're using it.

1. Moo based instead of Moose.

well, if you're not using Moose in your system, Moose may be too much for your speed. I am maintain a new branch on that which converted Moose to Moo. changes can be found at https://github.com/fayland/Net-Amazon-DynamoDB/commit/0b3b9a493e92c85461353ef1fc1da422e4d0bb48 and I'll update when the Moose version is updated.

2. custom Cache module supports.

I removed the isa => 'Cache' in the Moo version, instead, I'm using

has cache => ( isa => sub {
     die "thaw/freeze/remove must be supported in cache" unless $_[0]->can('thaw') and $_[0]->can('freeze') and $_[0]->can('remove')
}, is => 'rw', predicate => 'has_cache' );

so that we can use custom layer like

package My::Dummy::Cache::FastMmap;

use Moo;
use Cache::FastMmap;

has 'cache' => (is => 'lazy');
sub _build_cache { Cache::FastMmap->new(share_file => '/tmp/mycache_fastmmap', unlink_on_exit => 0) }

# Cache::FastMmap do not have thaw/freeze sub
sub thaw {
    my $self = shift;
    $self->cache->get(@_);
}
sub freeze {
    my $self = shift;
    $self->cache->set(@_);
}
sub remove {
    my $self = shift;
    $self->cache->remove(@_);
}

1;

I have fixed some bugs for the cache system like not set while return is undef, delete on batch_write etc. but it is still not perfect b/c it's not supported inside batch_get_items yet. I may write patch for it later.

3. set is not array.
well, for SS or NS. it's set. it's not array. it means there is not an order inside.
if you want something like order, we can join it as string and save it. after get, split back.

Thanks.



blog comments powered by Disqus