Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re^5: How do I save a Rose::DB::Object instance to Cache::Memcached::Fast and retrieve it?

by PerlOnTheWay (Scribe)
on Feb 10, 2012 at 11:44 UTC ( #952997=note: print w/ replies, xml ) Need Help??


in reply to Re^4: How do I save a Rose::DB::Object instance to Cache::Memcached::Fast and retrieve it?
in thread How do I save a Rose::DB::Object instance to Cache::Memcached::Fast and retrieve it?

Rose::DB::Object is not like a hash or array, so it won't work to simply throw it into memcached directly


Comment on Re^5: How do I save a Rose::DB::Object instance to Cache::Memcached::Fast and retrieve it?
Re^6: How do I save a Rose::DB::Object instance to Cache::Memcached::Fast and retrieve it?
by Anonymous Monk on Feb 10, 2012 at 12:06 UTC
      Thanks for the suggestion, but what's worse is that I'm caching Rose::DB::Object,not Rose::DB.

      And there seems no simple way to extract the hash it contains.

        Thanks for the suggestion, but what's worse is that I'm caching Rose::DB::Object,not Rose::DB.

        same difference

        http://search.cpan.org/grep?cpanid=JSIRACUSA&release=Rose-DB-Object-0.797&string=storable&i=1&n=1&C=0

        http://cpansearch.perl.org/src/JSIRACUSA/Rose-DB-Object-0.797/t/db-object-helpers.t

        my $o = $class->new(id => 1)->load_or_save; my $frozen = Storable::freeze($o->strip(strip_on_save_ok => 1)); my $thawed = Storable::thaw($frozen);

         

        And there seems no simple way to extract the hash it contains.

        http://cpansearch.perl.org/src/JSIRACUSA/Rose-DB-Object-0.797/lib/Rose/DB/Object/Cached.pm

        sub remember { my($self) = shift; my $class = ref $self; my $meta = $self->meta; my $pk = join(PK_SEP, grep { defined } map { $self->$_() } $meta->pr +imary_key_column_accessor_names); no strict 'refs'; my $ttl_secs = $class->meta->cached_objects_expire_in || 0; my $loaded = $ttl_secs ? time : 0; ${"${class}::Objects_By_Id"}{$pk} = $self; if($ttl_secs) { ${"${class}::Objects_By_Id_Loaded"}{$pk} = $loaded; } my $accessor = $meta->column_accessor_method_names_hash; foreach my $cols ($self->meta->unique_keys_column_names) { no warnings; my $key_name = join(UK_SEP, @$cols); my $key_value = join(UK_SEP, grep { defined($_) ? $_ : UNDEF } map { my $m = $accessor->{$_}; $self->$m() } +@$cols); ${"${class}::Objects_By_Key"}{$key_name}{$key_value} = $self; ${"${class}::Objects_Keys"}{$pk}{$key_name} = $key_value; if($ttl_secs) { ${"${class}::Objects_By_Key_Loaded"}{$key_name}{$key_value} = $l +oaded; } } };

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://952997]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (13)
As of 2014-08-28 14:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (263 votes), past polls