[Cl-perec-devel] Lots of questions :-)

Attila Lendvai attila.lendvai at gmail.com
Wed Sep 16 08:48:20 UTC 2009


> I have one more question: is there a way to use objects without
> "reviving instance"?  The reason I'd do that is that there are objects
> that change very infrequently, such as Users.  If I get an User object
> from the DB when a request comes in and I need to pass it around to
> various functions, it would be nice if they don't need to do
> (with-transaction (revive-instance user)) because that involves a
> (mostly useless) SELECT since the data is already there.


we do this in call-with-reloaded-authenticated-session here:

http://common-lisp.net/cgi-bin/darcsweb/darcsweb.cgi/darcsweb.cgi?r=cl-dwim-cl-dwim;a=headblob;f=/meta-model/authentication.lisp

the relevant line is this:

(setf authenticated-session (load-instance authenticated-session
:skip-existence-check #t :copy-cached-slot-values #t))

this way l-i will make a copy of the given p-o in the lisp vm, copy
over any cached slot information from the source, and cache it in the
transaction. as far as i remember, this is recursive, so be careful
with what slots are cached, because though *-to-n associations you can
end up copying a whole bunch of p-o's.

also note that there's no version handling yet, so make sure you don't
modify such an object, because it will write back the cached slot
values, which may be long-long minutes old...

-- 
 attila




More information about the cl-perec-devel mailing list