Re: How to persist and query a hash lookup in memory with Perl ?



On Nov 29, 9:56 am, Jim Gibson <jimsgib...@xxxxxxxxx> wrote:
In article
<7c5df670-d214-40c2-b59d-9ba1f5785...@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>,





<jackposem...@xxxxxxxxx> wrote:
On Nov 28, 6:37 pm, Gunnar Hjalmarsson <nore...@xxxxxxxxx> wrote:
Jack wrote:
Hi I have a web application that needs to on an adhoc basis query a
hash lookup which should be persisted in memory - I have seen this
module "Persistent::Memory - A Persistent Class implemented using
Memory (RAM)" but I wanted to see if there was a much simpler approach
to taking a hash map and making it 'callable' while persisted in
memory using standard features not requiring a special Perl module
install..

Any thoughts would be appreciated.

Why not a tied hash? See e.g. "perldoc DB_File".

--
Gunnar Hjalmarsson
Email:http://www.gunnar.cc/cgi-bin/contact.pl

Hi and thank you however that looks too complex - just trying to put a
hash in memory, why is that so hard to do ? Is there a simpler way ?

Your question is confusing. All Perl variables, including hashes, are
in memory. The trick to achieving "persistence" between execution
instances of your web application is to have the data on a permanent
data store, such as a disk file. Memory variables disappear once your
Perl process terminates. Using a tied hash, per Gunnar's suggestion, is
one way to accomplish this. There are others, such as using the
Storable module to serialize your hash so you can write it to memory.

I have not use Persistent::Memory, but you might want to check out the
Persistent::File module instead. Both of those modules seem to be part
of the Persistent framework of Perl modules.

See
<http://search.cpan.org/~dwinters/Persistent-Base-0.52/lib/Persistent.po
d>

--
Jim Gibson

Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com- Hide quoted text -

- Show quoted text -

Thanks I am willing to install Perl Modules, really wondering if there
is a native ability to do it out of the box in Perl. I got persistent
memory to work but its not clear how to "pin" a hash lookup into
memory since .pl files and the persistent memory code example itself
are only as good as the life of the execution of the script !! Still
not clear how to hold a has in Memory - even if you were to create a
windows service out of it with activestate PDK, not clear how to write
the script so the script doesnt stop execution but sits and waits for
a socket connection or something.. Do I just have script 1 generate
a hash with "sleep forever" and then script 2 can call that hash ??
I dont want to use another database for this. So, not using another
DB, how does one pin and persist and then query a hash in memory using
perl or a perl module.

Thanks for the help all !
Jack
.



Relevant Pages

  • Re: How to persist and query a hash lookup in memory with Perl ?
    ... hash lookup which should be persisted in memory - I have seen this ... Memory " but I wanted to see if there was a much simpler approach ... memory using standard features not requiring a special Perl module ... The trick to achieving "persistence" between execution ...
    (comp.lang.perl.misc)
  • Re: DBI (with Oracle) out of memory error
    ... Hashes need a lot of memory. ... With 280k hash keys, I estimate that your ... How much memory does your script use just before it runs out of memory? ... And I just prefer to store the data in a hash rather than ...
    (comp.lang.perl.misc)
  • Re: How to persist and query a hash lookup in memory with Perl ?
    ... hash lookup which should be persisted in memory - I have seen this ... Memory " but I wanted to see if there was a much simpler ... Perl module install.. ... If you aren't willing to install modules and you aren't willing to use the ...
    (comp.lang.perl.misc)
  • Re: out of memory
    ... Your program is using more memory than ulimit allows. ... files and create hash table and then use tht hash for final output. ... were created my child processes in my previous script and create hash. ...
    (comp.lang.perl.misc)
  • Re: Reference to a hash as argument for a plperl-function
    ... Hash: RIPEMD160 ... argument to a plperl-function in a Postgresql-database? ... No: the hash is in the memory of your DBD::Pg script, ...
    (perl.dbi.users)