Complex structure vs object This is not, strictly speaking, code review, but I think my question can be asked here.

This is a request to find out what seems to be the cleanest. This project is a blog engine that uses the file system.  There are still many things to do to improve the code (it's not great).  I have such a class article at initialization that will parse actual items and store it in a structure and CHI a cache system.  In CHI, I store a table of hash:

 push(
     @articles,
     {
         title   =&gt; $title,
         tags    =&gt; \@tags,
         date    =&gt; $dt,
         content =&gt; $content,
         link    =&gt; $url
     }
 );


I wonder if it would not be better to make a class item and store it in my cache as an object list:

 package MahewinBlogEngine::Article;

 use Moo;

 use Type::Params qw( compile );
 use Type::Utils;
 use Types::Standard qw( Object Str Int ArrayRef );

 has title =&gt; (
     is       =&gt; 'rw',
     isa      =&gt; Str,
     required =&gt; 1,
 );

 has tags  =&gt; (
     is       =&gt; 'rw',
     isa      =&gt; ArrayRef,
     required =&gt; 1,
 );

 has date  =&gt; (
     is       =&gt; 'rw',
     isa      =&gt; Object,
     required =&gt; 1,
 );

 has content =&gt; (
     is       =&gt; 'ro',
     isa      =&gt; Str,
     required =&gt; 1,
 );

 has link =&gt; (
    is       =&gt; 'ro',
    isa      =&gt; Str,
    required =&gt; 1,
 );

 1;


And:

 my $article =  MahewinBlogEngine::Article-&gt;new(
     title   =&gt; $title,
     tags    =&gt; \@tags,
     date    =&gt; $dt,
     content =&gt; $content,
     link    =&gt; $url
);

push(@articles, $article);


This makes objects more maneuverable, powerful and extensible.  It also allows you to add methods such as formatting or other things.  But at the moment, I see no specific methods.  It will simply be a class with attributes and accessors. So, I wonder what is best in terms of quality, performance and memory.

Another question: I think CHI already compresses, but do you think it would be wise to use Sereal and compress before storing in the CHI system cache?
The CHI uses many caching backends and you did not said which one you are using. Fastest is perl's internal arrays, then hashes and then any other implementations. CHI may use persistent files to caching, like Berkeley DB backend or one of mmap implementation to reduce memory usage. When you are using such caching to improve perfomance you may place cache files to tmpfs (or some of ramfs) on *nix systems (linux, *bsd).

So, when I'm storing a lot of data in cache and I need to reduce memory usage I prefer use BDB without CHI. Then I need speed and managing few data in cache I prefer perl's internal structures. In last case you need to remember that Perl uses optimistic memory allocation. Thats means that Perl reallocates and allocates new memory segments and never returns consumed memory back to the OS. It is very important when writing daemons and you need to limit somehow memory usage. In other cases you may use any caching system and do not worry about performance or memory usage. Just use Devel::NYTProf to find bottlenecks.