package App::Commentry::CommentStore;

use aliased 'App::Commentry::CommentSet';
use Moo;

has base_dir => (is => 'ro', required => 1);

has _cache => (
  is => 'ro', init_arg => undef,
  lazy => 1, default => sub { {} },
  clearer => 'clear_cache'
);

sub get {
  my ($self, $proto) = @_;
  my $path = $proto->{path} or die "->get requires a path key";
  $self->_cache->{$path} ||= do {
    CommentSet->new(base_dir => $self->base_dir, path => $path)
  };
}

1;
