I have several Moose objects and some other simple hash objects (hashes, arrays) that I would like to serialize.
At first I used a simple
my $obj_store_file = nstore($obj);
and
my $obj = retrieve($obj_store_file);
It worked out well.
Later I found near MooseX::Storage and KiokuDB . I tried to use them to take advantage of some of the benefits they have, but:
MooseX::Storage seemed to recreate objects that are transferred multiple times. For example, one of my serialized objects contains several attributes, each of which refers to one instance of another object. Before serialization, all of these links are obviously the same - they all point to the same object. After serialization / deserialization using MooseX::Storage this one object is duplicated once, and each link points to a different instance of the object. I was told that MooseX::Storage not suitable for representing graphs of objects and that I can try KiokuDB .- I did, although I felt that
KiokuDB is redundant for my needs. I donβt need all the fancy stuff the DB can offer. Unfortunately, since one of my objects is really large and changes memory during a sequential conversion using the default values, it seems to me that I should write my own serializer or save its βdataβ separately, and then write a suit of KiokuX::Module ... again, pretty overkill.
So, I will return to ordinary or YAML. My question is simple: yes, there are some advantages to KiokuDB (especially the fact that it supports an object graph) and, possibly, also to MooseX::Storage (although I could not find them for the latter). But, considering that these advantages are not very useful for me, is there any reason not to use Storable or YAML?
In other words, is there something wrong with saving the object (Moose) this way? It's illegal?
source share