Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

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

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


in reply to Re^6: 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?

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.


Comment on Re^7: How do I save a Rose::DB::Object instance to Cache::Memcached::Fast and retrieve it?
Re^8: 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:37 UTC

    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; } } };

      The serilization works by hooks, which connects and fetches data from the db .

      I'm worried of one thing:

      Will it make caching the data nonsense since whether or not it's in cache , db connection is involved any way.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (7)
As of 2014-07-23 02:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (131 votes), past polls