Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: object identity in DBIx::Class

by spx2 (Deacon)
on Apr 24, 2009 at 14:50 UTC ( [id://759853]=note: print w/replies, xml ) Need Help??


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.

Replies are listed 'Best First'.
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.

      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.

        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.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (5)
As of 2024-03-19 08:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found