in reply to object identity in DBIx::Class
Yeah,sub-class DBIx::Class and cache the objects it gives you with a expiry time of your choice,and define the 'time' as you want(maybe number of calls to ->find or maybe time in the usual sense),then you'll probably have the desired effect which may or may not be what you want,for alot of queries that cache may become kind of heavy on your memory usage.
I'm looking forward to knowing if there's any built-in feature for DBIx::Class that does this.
Re^2: object identity in DBIx::Class
by perrin (Chancellor) on Apr 24, 2009 at 15:17 UTC
|
Caching is not what the OP asked for. It's more like the object uniqueness feature that Class::DBI had. No idea if DBIx::Class supports something similar. | [reply] [Watch: Dir/Any] |
|
he wants the exact same results to be returned on a second call to ->find.
what he didn't envision is a scenario where you have multiple processes writing in the db and ->find with the same arguments could return a totally different thing,so what he wants isn't very "thread-safe"(although ironically Perl has no usable threads from what I was told on multiple occasions).
if he has just one process writing on the db then you're right,he could just switch to Class::DBI,and read this.
| [reply] [Watch: Dir/Any] |
|
and ->find with the same arguments could return a totally different thing
Please note that I am not talking about arbitrary finds but finds for a primary key (maybe I made myself not clear).
What I want is (within one process) one db-entity (where indentity is given by primary key) to be represented at the object-level by the one and only one instance.
It would lead too far to explain why this is important to me.
Different processes would be in different transactions, that's no problem at all.
ironically Perl has no usable threads
Not true (and without any relevance for the question at hand).
switch to Class::DBI,and read this.
I have been thinking about building a cache using weak references myself, thanks for the link.
| [reply] [Watch: Dir/Any] |
|