Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

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 ( [id://953007]=note: print w/replies, xml ) Need Help??


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

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; } } };
  • Comment on Re^8: How do I save a Rose::DB::Object instance to Cache::Memcached::Fast and retrieve it?
  • Select or Download Code

Replies are listed 'Best First'.
Re^9: How do I save a Rose::DB::Object instance to Cache::Memcached::Fast and retrieve it?
by PerlOnTheWay (Monk) on Feb 10, 2012 at 13:31 UTC

    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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://953007]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (7)
As of 2024-04-18 07:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found