FAQ
Hi,

We have multiple developers running the same application on different
ports.

Since they share the same cache (FileCache defaults to /tmp/FileCache),
and the port isn't part of the cache key
(&PageCache::_get_page_cache_key), we are getting cached pages served
incorrectly.

Ideally I'd like to specify the port as part of the cache storage
location:

package MyApp;

use Catalyst qw/Cache::FileCache PageCache/;

# make sure caches for apps running on different ports do not conflict
__PACKAGE__->config->{cache}->{storage} = "tmp/FileCache/$PORT";

Is this the right way to do it?

And how can I get the port variable here? Its passed down to
Catalyst::Engine::*, but I don't see any accessors.

Thanks,

Richard Jolly

Search Discussions

  • Richard Jolly at Jan 4, 2006 at 3:45 pm

    Richard Jolly wrote:
    Hi,

    We have multiple developers running the same application on different
    ports.
    Replying to myself...

    I realized that the pid will give better protection than the port
    anyway. So I've got:

    __PACKAGE__->config->{cache}->{storage}
    = catfile( File::Spec::Functions::tmpdir, 'FileCache', $$ );

    which works well.

    Richard

    http://www.bbc.co.uk/

    This e-mail (and any attachments) is confidential and may contain
    personal views which are not the views of the BBC unless specifically
    stated.
    If you have received it in error, please delete it from your system.
    Do not use, copy or disclose the information in any way nor act in
    reliance on it and notify the sender immediately. Please note that the
    BBC monitors e-mails sent or received.
    Further communication will signify your consent to this.
  • Andy Grundman at Jan 4, 2006 at 3:52 pm

    Richard Jolly wrote:
    I realized that the pid will give better protection than the port
    anyway. So I've got:

    __PACKAGE__->config->{cache}->{storage}
    = catfile( File::Spec::Functions::tmpdir, 'FileCache', $$ );
    This will work but you'll be creating a new cache on each restart and filling up
    /tmp/FileCache with lots of old cache dirs.

    -Andy
  • Andy Grundman at Jan 4, 2006 at 3:50 pm

    Richard Jolly wrote:
    Hi,

    We have multiple developers running the same application on different
    ports.

    Since they share the same cache (FileCache defaults to /tmp/FileCache),
    and the port isn't part of the cache key
    (&PageCache::_get_page_cache_key), we are getting cached pages served
    incorrectly.
    I'll fix and release a new version of PageCache that creates a more unique key.
    Ideally I'd like to specify the port as part of the cache storage
    location:

    package MyApp;

    use Catalyst qw/Cache::FileCache PageCache/;

    # make sure caches for apps running on different ports do not conflict
    __PACKAGE__->config->{cache}->{storage} = "tmp/FileCache/$PORT";

    Is this the right way to do it?
    Right, you can also do this, but PageCache's key should still be more unique.
    And how can I get the port variable here? Its passed down to
    Catalyst::Engine::*, but I don't see any accessors.
    The port can be found in $c->req->uri->port.

    -Andy
  • Richard Jolly at Jan 4, 2006 at 3:57 pm

    Richard Jolly wrote:
    Richard Jolly wrote:
    Hi,

    We have multiple developers running the same application on different
    ports.
    Replying to myself...

    I realized that the pid will give better protection than the port
    anyway. So I've got:

    __PACKAGE__->config->{cache}->{storage}
    = catfile( File::Spec::Functions::tmpdir, 'FileCache', $$ );

    which works well.
    Replying to myself again (hopefully this will help somebody in the
    future):

    There is no need to change the storage location, as Cache::Cache has a
    namespace configuration option to handle this:

    __PACKAGE__->config->{cache}->{namespace} = $$;

    Richard

    http://www.bbc.co.uk/

    This e-mail (and any attachments) is confidential and may contain
    personal views which are not the views of the BBC unless specifically
    stated.
    If you have received it in error, please delete it from your system.
    Do not use, copy or disclose the information in any way nor act in
    reliance on it and notify the sender immediately. Please note that the
    BBC monitors e-mails sent or received.
    Further communication will signify your consent to this.
  • Brandon Black at Jan 4, 2006 at 5:18 pm

    On 1/4/06, Richard Jolly wrote:
    Replying to myself...

    I realized that the pid will give better protection than the port
    anyway. So I've got:

    __PACKAGE__->config->{cache}->{storage}
    = catfile( File::Spec::Functions::tmpdir, 'FileCache', $$ );

    which works well.
    Replying to myself again (hopefully this will help somebody in the
    future):

    There is no need to change the storage location, as Cache::Cache has a
    namespace configuration option to handle this:

    __PACKAGE__->config->{cache}->{namespace} = $$;
    I would suspect the best all-around cache namespace key would be the
    complete base url of the application, as in
    "http://myserver.mycompany.com:1234/Stuff/CatAppRoot". All of that
    should be determinable from within Catalyst regardless of the Engine
    in use.

    -- Brandon

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupcatalyst @
categoriescatalyst, perl
postedJan 4, '06 at 3:11p
activeJan 4, '06 at 5:18p
posts6
users3
websitecatalystframework.org
irc#catalyst

People

Translate

site design / logo © 2021 Grokbase