in reply to Sitewide states in a web application (specifically cache locking in Catalyst)

i don't know about Catalyst, but basically there are many ways of storing data between processes. the most performant solution would lie in using shared memory. you create the shmem segment in the startup.pl of your application, and any of the app's pages store the common data on it and read from there.
for instance startup.pl might look like (assuming all of the application's global data are stored in a hashtable called %appdata):
use IPC::Shareable ':lock'; [...] no warnings 'untie'; my $knot; my $glue = "SHMEMGLUE"; eval { $knot = tie %tie, 'IPC::Shareable', $appdata{$glue}, { create = +> 0, mode => 0666, size => $appdata{SHMEMSIZE}, exclusive + => 0, destroy => 0 }; }; unless ($@) { $knot->remove; untie %tie; undef $knot; } $knot = tie %tie, 'IPC::Shareable', $appdata{$glue}, { create => 1, mo +de => 0666, size => $appdata{SHMEMSIZE}, exclusive => + 0, destroy => 0 }; untie %tie;
note: this code first tries to find the shmem segment, and if it exists it destroys it. this prevents you from allocating additional memory with each restart of apache.

--------------------------------
masses are the opiate for religion.
  • Comment on Re: Sitewide states in a web application (specifically cache locking in Catalyst)
  • Download Code

Replies are listed 'Best First'.
Re^2: Sitewide states in a web application (specifically cache locking in Catalyst)
by Ionitor (Scribe) on Jun 30, 2007 at 09:50 UTC
    Yeah, I'm aware of IPC::Shareable. Since I'd like to be able to develop this under Win32 (which seems to like the IPC::Semaphore that Shareable depends on) I'd probably end up using a different module with the similar abilities (any recommendations there?). Mainly, modules like that are somewhat low level, and I was hoping I could be lazy and use a module that takes care of issues like locking and memory allocation.