#!/usr/bin/perl -w use Storable qw( freeze thaw ); use DB_File; use strict; my %hash = ( 1 => { desc => 'fat', states => 'WA OR ID CA', open => '0', narm => '1', }, 2 => { desc => 'fatter', states => 'NATIONWIDE OR ID CA', open => '1', narm => '0', }, ); my $frozen = freeze \%hash; my %table; tie (%table, 'DB_File', 'planners.db', O_RDWR|O_CREAT, 0666, $DB_BTREE) or die "Cannot tie: $!"; %table = ( planners => $frozen, ); untie %table;

%table will be used to generate HTML pages throughout a website, and could grow to 5 key/value pairs. %hash would get up to a maximum of 200 key/value pairs. I want to keep %table alive in memory (I'm using mod_perl), and unfreeze/uncompress the values as I need them. Would Compress::Zlib work to keep %table's size in memory to a minimum? Is there another way that I can keep %table very small in memory, assuming CPU is not a bottleneck?

In reply to Compression of a mini-database in memory by meonkeys

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.