Quiq::Storable - Persistenz für Perl-Datenstrukturen
Quiq::Object
Die Klasse ist ein objektorientierter Wrapper für das Core-Modul Storable, speziell für die Funktionen freeze(), thaw(), clone().
$cloneRef = Quiq::Storable->clone($ref);
$str = Quiq::Storable->freeze($ref);
$ref = Quiq::Storable->thaw($str);
$ref = Quiq::Storable->memoize($file,$sub);
Existiert Datei $file, deserialisiere die enthaltene Datenstruktur. Andernfalls erzeuge die Datenstruktur durch Aufruf der Subroutine $sub und speichere sie in Datei $file. In beiden Fällen liefere eine Referenz auf die Datenstuktur zurück.
Soll die Datenstuktur erneut generiert werden, genügt es, die Datei zuvor zu löschen.
Cache Hash mit zyklischer Struktur:
my $cacheFile = '~/tmp/test5674'; my $objectH = Quiq::Storable->memoize($cacheFile,sub { my $h; $h->{'A'} = [1,undef]; $h->{'B'} = [2,undef]; $h->{'A'}[1] = \$h->{'B'}; $h->{'B'}[1] = \$h->{'A'}; return $h; });
1.139
Frank Seitz, http://fseitz.de/
Copyright (C) 2019 Frank Seitz
This code is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Quiq, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Quiq
CPAN shell
perl -MCPAN -e shell install Quiq
For more information on module installation, please visit the detailed CPAN module installation guide.