http://www.perlmonks.org?node_id=480737

jeteve has asked for the wisdom of the Perl Monks concerning the following question:

Hi monks. Here is my quest:

I wish to store a collection of heterogeneous objects under a key name in order to make them persistent. I don't need to query them, I just need to be able to give the key and retrieve the collection. I also like to use a RDMS server as storage backend.

I had a look to *Session* ( like CGI::Session ) or *Cache* (like Cache::FileCache ) but theses storage are dedicated to store temporaly objects so they don't really fit my needs since object destiny is to expire within those storages.

I also had a look at data serializers like Data::Serializer, but it don't seem able to use a database as storage backend.

What would you do you wise monks to cope with that issue ?
Thx !
Nice photos of naked perl sources here !
  • Comment on Best way to store an object collection.

Replies are listed 'Best First'.
Re: Best way to store an object collection.
by davorg (Chancellor) on Aug 04, 2005 at 09:33 UTC
      Wooow, it rocks :)
      Nice photos of naked perl sources here !
Re: Best way to store an object collection.
by knoebi (Friar) on Aug 04, 2005 at 09:43 UTC
Re: Best way to store an object collection.
by anonymized user 468275 (Curate) on Aug 04, 2005 at 09:34 UTC
    perltie seems appropriate - although the documentation foucuses on tying hashes, scalars and array, don't let this fool you - tie is just as good at tying objects to database entries.

    One world, one people

Re: Best way to store an object collection.
by srdst13 (Pilgrim) on Aug 04, 2005 at 13:54 UTC

    You may want to look at Tie::DBI. If you have a complex data structure associated with each key (a complex hash of hashes, or the like), you can use Storable, Data::Dumper, or YAML to serialize the data structure to text and store that.

    For a more database-centric view of things, look at Class::DBI.

    Sean

Re: Best way to store an object collection.
by InfiniteLoop (Hermit) on Aug 04, 2005 at 20:59 UTC
      And how does that make the objects persistent?

      /J

Re: Best way to store an object collection.
by kwaping (Priest) on Aug 04, 2005 at 23:21 UTC
    Are you talking about storing in RAM or in a file?