I don't really know if the list is the right place to do this, but attached
is a hack of what I had for my Cached FastMmap module converted over to CHI.
I've tested the basic functionality, but don't know if this is really the
correct way to implement it.
 
I like the idea of CHI and would like to be able to do something along the
lines of selecting the cache driver I want to use with my script that starts
my process.  In one script I may want to set my Rose Objects to use a Memory
cache, but in my FastCGI or modperl process I may want it to use FastMmap.
I keep thinking an environment variable of some sort, but there has to be a
better way, right?
 
 
-Kevin

  _____  

From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Sam
Tregar
Sent: Thursday, February 07, 2008 12:54 PM
To: Rose::DB::Object list
Subject: Re: [RDBO] Anyone done more advanced caching with rdbo?


On Feb 7, 2008 9:40 AM, Kevin McGrath <[EMAIL PROTECTED]> wrote:


I've actually been working on a Cached::FastMmap module for my own project a
My::DB::Object::Cached::FastMmap type module.  I wanted to test using
FastMmap because I want my application to use the same cache across
different processes.  So far it's been a success and I've now been working
on trying to make it more generic.

I'd be willing to help with coming up with a module that does this, I would
definitely have an interest for it.



Instead of using Cache::FastMmap directly, how about using CHI:

   http://search.cpan.org/~jswartz/CHI/

That would let you experiment with different backends without changing your
code.  I haven't tried it yet but I've heard good things.

-sam


#### Within Metadata Class ###

### By default there will be namespace for every
### class.  But if a lot of classes are loaded a new
### FastMmap file will need to be created for each one.
### Keys are set in a way that we could use a global namespace
### if we wanted to here, so only one FastMmap file is created.

sub defalut_cache_settings {
# Over-ride in own meta class

    my %default = (
        driver=>'FastMmap',
        #root_dir=>'/tmp/RDBO-global',
        #namespace=>'global_namespace',
    );

    return %default;
}



sub cache_settings {
    my $self = shift;
    my @args = @_;

    my %settings;

    unless (defined $self->{__cache_settings}) {
        %settings = __PACKAGE__->defalut_cache_settings();
        $self->{__cache_settings} = \%settings;
    }

    if ($args) {
        push @{%settings}, @args;
        $self->{__cache_settings} = \%settings;
    } else {
        return $self->{__cache_settings}
    }

}


sub cache_handle {
    my $self = shift;
    my $handle = shift;

    if ($handle) {
        $self->{__cache_handle} = $handle;
    } else {
        return $self->{__cache_handle}
    }

}

Attachment: CachedCHI.pm
Description: Binary data

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object

Reply via email to