You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Greg Cope <gj...@rubberplant.freeserve.co.uk> on 2000/07/21 20:58:10 UTC

YAM (Yet Another Module) - an IPC shared cache thing - anyone interested ?

Dear All

I've writen a small IPC sysV based shared cache thingy ... (useing
IPC::ShareLite), and I'd like some comments oin the design if anywants
to crtique...

Why / the problem:

I work in a dept where the coderes (Me !) code, and the HTML design
people do HTML.  The only commonality we share is that we agree on a tag
name (place holder ... where they want my dynamic content to go) and the
size of the content to be placed.  They then create the HTML (templates)
with tags, and I code perl that looks for these tags in the templates.

Nothing special so far. (The templating module is very, very simple and
only deals with new tags and
templates).

When mod_perling I used to load all the templates into an object that
had one class attribute - a hash of these templates.  The apache
children can create a new object(s) that will have the templates in the
class attribute 'cache'.  This is fine until you want to change anything
- you need an apache restart.  This was not really an issue, until we
had a new design which had often changing nav bars because new sections
are added / removed (often being daily sometimes hourly at times).

A Solution

Not whishing to use mod_perl to create any semi dynamic data (changes
daily /
hourly) etc. I thought about Sysv shared memory and
IPC::ShareLite.  Having had a "classical" Database training, I normalise
everything into modules quite aggressively (or at least try to think I
do).

Hence I want these templates in memory, and shared by all processes -
so that if a change needs to be made an exterior process can change one
or more
cache entr{y|ies}, and all apache children will then use the new cached
template.

Apart from security of the Shared memory - I see no major issues - but I
be looking through rose tinted specs...

Can any one see any major issues with this from a mod_perl prespective ?

If anyones interested in having a look see - drop me a line - as I'll
have to clear it up a bit !

Greg Cope



Re: YAM (Yet Another Module) - an IPC shared cache thing - anyone interested ?

Posted by Greg Cope <gj...@rubberplant.freeserve.co.uk>.
Francesco Pasqualini wrote:
> 
> is it possible to use IPC sysV  to share DBI connection between apache
> childs ?

IIRC this is not possible as DBI connections are special magic things -
this was discussed on the list a few months back - but I cannot remember
the name of the thread.


Greg Cope
 
> What I'm looking for is the possibility to store a DBI connections in the
> $Session
> object (Apache::ASP or Apache::Session).
> In this way we can start a DB connection for each user session and we can
> have different application using differnet DB.
> 
> The connection is started when the user session start, is maintened in
> memory, it is visible to all the apache childs and will be closed at session
> end.
> 
> thanks
>

Re: YAM (Yet Another Module) - an IPC shared cache thing - anyone interested ?

Posted by Francesco Pasqualini <f....@cpsinformatica.it>.
is it possible to use IPC sysV  to share DBI connection between apache
childs ?

What I'm looking for is the possibility to store a DBI connections in the
$Session
object (Apache::ASP or Apache::Session).
In this way we can start a DB connection for each user session and we can
have different application using differnet DB.

The connection is started when the user session start, is maintened in
memory, it is visible to all the apache childs and will be closed at session
end.


thanks

----- Original Message -----
From: "Greg Cope" <gj...@rubberplant.freeserve.co.uk>
To: "Modperl list" <mo...@apache.org>
Sent: Friday, July 21, 2000 8:58 PM
Subject: YAM (Yet Another Module) - an IPC shared cache thing - anyone
interested ?


> Dear All
>
> I've writen a small IPC sysV based shared cache thingy ... (useing
> IPC::ShareLite), and I'd like some comments oin the design if anywants
> to crtique...
>



Re: YAM (Yet Another Module) - an IPC shared cache thing - anyone interested ?

Posted by Greg Cope <gj...@rubberplant.freeserve.co.uk>.
Joshua Chamas wrote:
> 

> I would recommend using Apache::ASP as it does everything you need.
> First it allows for creation of your dynamic tags:
> 
>   http://www.nodeworks.com/xml.html
> 
> It will reload all of your templates dynamically at runtime, for
> ease of development but also has advanced server startup parent
> httpd compilation abilities for greatest scalability, where templates
> are shared across child forks:
> 
>   http://www.nodeworks.com/asp/tuning.html#Precompile%20Scripts
> 
> Finally, it will give your designers a comfortable ASP scripting
> environment, while giving you the developer powerful APIs like
> the Script_OnStart event which you can use to customize the
> global environment available to each script:
> 
>   http://www.nodeworks.com/asp/events.html#Script_OnStart%20%26%20Script_OnEnd
> 
> If you think its scarey that designers might be able to execute
> arbitrary perl code in <% %> blocks, I have thought about allowing
> a config option to turn these blocks off, so the compiler will
> just strip them or render the raw code by default.  Might be like
> 
>   PerlSetVar CodeBlocks 0
> 
> This way, your designers would only be able to use the custom tags
> that you provide for them.


Thanks Joshua

I was aware that Apache::ASP did all the some of these things but not
all of this - and I see you will be including some XML support .... I am
truely impressed (the caching bit, and the script environment changes).

My aims have thus far been to write my own modules that just do what I
need and no more, so that Firstly its efficient (no excess code, not to
say Apache::ASP has any of that ;-), and Secoundly to learn some more.

This does mean I reinvent the wheel code wise, compared to projects like
yours, HTML::Embperl, HTML::Template - but I'll learning in the mean
time.  I am not expecting to release anything on CPAN or for the code to
be used by anyone else.

If anything I've been introduced to HML::Template - which is just the
lightwieght templating module that would help with my present (work)
project (I'd use my own  module, but using a maintained CPAN module
would be better for my clients in the long term (i.e after I've left)).

Thanks again for the pointer.

Greg Cope

> 
> -- Joshua
> _________________________________________________________________
> Joshua Chamas                           Chamas Enterprises Inc.
> NodeWorks >> free web link monitoring   Huntington Beach, CA  USA
> http://www.nodeworks.com                1-714-625-4051


Re: YAM (Yet Another Module) - an IPC shared cache thing - anyone interested ?

Posted by Joshua Chamas <jo...@chamas.com>.
Greg Cope wrote:
> 
> Dear All
> 
> I've writen a small IPC sysV based shared cache thingy ... (useing
> IPC::ShareLite), and I'd like some comments oin the design if anywants
> to crtique...
> 
> Why / the problem:
> 
> I work in a dept where the coderes (Me !) code, and the HTML design
> people do HTML.  The only commonality we share is that we agree on a tag
> name (place holder ... where they want my dynamic content to go) and the
> size of the content to be placed.  They then create the HTML (templates)
> with tags, and I code perl that looks for these tags in the templates.
> 

I would recommend using Apache::ASP as it does everything you need.
First it allows for creation of your dynamic tags:

  http://www.nodeworks.com/xml.html

It will reload all of your templates dynamically at runtime, for
ease of development but also has advanced server startup parent 
httpd compilation abilities for greatest scalability, where templates 
are shared across child forks:

  http://www.nodeworks.com/asp/tuning.html#Precompile%20Scripts
  
Finally, it will give your designers a comfortable ASP scripting
environment, while giving you the developer powerful APIs like
the Script_OnStart event which you can use to customize the
global environment available to each script:

  http://www.nodeworks.com/asp/events.html#Script_OnStart%20%26%20Script_OnEnd

If you think its scarey that designers might be able to execute
arbitrary perl code in <% %> blocks, I have thought about allowing
a config option to turn these blocks off, so the compiler will
just strip them or render the raw code by default.  Might be like 

  PerlSetVar CodeBlocks 0

This way, your designers would only be able to use the custom tags
that you provide for them.

-- Joshua
_________________________________________________________________
Joshua Chamas			        Chamas Enterprises Inc.
NodeWorks >> free web link monitoring	Huntington Beach, CA  USA 
http://www.nodeworks.com                1-714-625-4051

Re: YAM (Yet Another Module) - an IPC shared cache thing - anyone interested ?

Posted by Perrin Harkins <pe...@primenet.com>.
On Fri, 21 Jul 2000, Greg Cope wrote:
> I've writen a small IPC sysV based shared cache thingy ... (useing
> IPC::ShareLite), and I'd like some comments oin the design if anywants
> to crtique...

Can you explain how your approach is different from the ones in
IPC::Shareable, IPC::Cache, IPC::SharedCache, IPC::MM (using shared hash),
File::Cache, and BerkeleyDB, and list some advantages/disadvantages of
your module?  Your module may be great, but it's hard for people to know
which one to use in this crowded field without some explanation of the
differences.

- Perrin


Re: YAM (Yet Another Module) - an IPC shared cache thing - anyoneinterested ?

Posted by Greg Cope <gj...@rubberplant.freeserve.co.uk>.
"T.J. Mather" wrote:
> 
> Have you considered using HTML::Template?  It is a simple yet powerful way
> to seperate HTML from Perl code.  It can do loops (good for HTML
> tables), includes, and if/unless/else statements.  Furthermore, it has
> shared memory for templates built in.
> 
> http://theoryx5.uwinnipeg.ca/mod_perl/cpan-search?dist=HTML-Template-1.8

Thanks for that.

Looking at that lead me IPC::SharedCache - which is almost exactly what
I have decided to do - albiet Sam Tregar's implementation appears alot
better.

My Implentation of the template is very simple - i.e you give it a
template, then ask it to sub in all the values into the tag locations,
and return a scalar ref.  There are a few other methods (for defining
tags and their values) -p but thats it.

I seem to have implemented an HTML::TemplateLite and IPC:SharedCacheLite
.... I have learned alot and can always reuse the code in the orginals -
this is after all perl ....

Thanks again.

Greg Cope



Re: YAM (Yet Another Module) - an IPC shared cache thing - anyone interested ?

Posted by "T.J. Mather" <tj...@thoughtstore.com>.
Have you considered using HTML::Template?  It is a simple yet powerful way
to seperate HTML from Perl code.  It can do loops (good for HTML 
tables), includes, and if/unless/else statements.  Furthermore, it has
shared memory for templates built in.

http://theoryx5.uwinnipeg.ca/mod_perl/cpan-search?dist=HTML-Template-1.8