Re: Progress report
From: Erann Gat (gNOSPAMat_at_flownet.com)
Date: 03/28/04
- Next message: Erann Gat: "Re: Progress report"
- Previous message: David Fisher: "Re: Flaw in Conditions System?"
- In reply to: Rahul Jain: "Re: Progress report"
- Next in thread: Erann Gat: "Re: Progress report"
- Reply: Erann Gat: "Re: Progress report"
- Reply: Rahul Jain: "Re: Progress report"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sun, 28 Mar 2004 11:25:18 -0800
In article <87zna0oqee.fsf@nyct.net>, Rahul Jain <rjain@nyct.net> wrote:
> gNOSPAMat@flownet.com (Erann Gat) writes:
>
> > It turns out I didn't even need any fancy tricks like a STORABLE mixin or
> > a before method on slot-value. SXHASH was all I needed to manage the
> > cache.
>
> That's because you require an explicit STORE operation on the whole
> object after mutation instead of extending (SETF S-V-U-C) to do the
> STORE implicitly on the mutated slot-value.
>
> But now that I think about it, there's really no difference in the
> programmer effort involved.
Yes, that's the conclusion I came to. The programmer has to tell the
system somehow what they do and do not want stored.
> The only "problem" is that the persistence
> layer needs to _recursively_ check _all_ slot-values to see if they've
> changed.
No, this is the really cool thing. Once you've stored an object, as long
as that object hasn't be GC'd it's in the cache along with its sxhash the
last time it was stored. So to update everything in the DB you just walk
through the cache and compare the cached stored sxhash with the current
actual sxhash and if they differ you need to re-store the object. So the
programmer only has to STORE things once. Thereafter they can just call
SYNC and everything that is STOREd that needs to be updated will be.
I didn't demonstrate this because I hadn't implemented it, but it's trivial:
(define-method (sync (db odb hash-cache))
(loop for o being the hash-keys of hash-cache do
(unless (= (ref hash-cache o) (sxhash o)) (store db o))))
and now I can demonstrate it:
? (sync db)
NIL
? x
(A B C D)
? (setf (car x) 'z)
Z
? (sync db)
1898: replace CONS(id,hash,CAR,CDR) values(1324,378158984,1319,1321)
NIL
?
That took me literally less than three minutes.
(I just realized that sxhash doesn't quite do the right thing. It will
generally cause you to store more stuff than is really necessary. But
it's easy enough to write a new hash function that does the Right Thing.)
> Have you looked at (un)CommonSQL, btw? It's not quite the same, in that
> it's not intended to be a proper object store, but rather a way of
> building instances based on relational data -- slots can be defined to
> be joins, e.g.
Yes, I have. It's much more complex and sophisticated than what I'm
doing. My project is designed to be lightweight. Also, (un)CommonSQL
doesn't work on MCL.
E.
- Next message: Erann Gat: "Re: Progress report"
- Previous message: David Fisher: "Re: Flaw in Conditions System?"
- In reply to: Rahul Jain: "Re: Progress report"
- Next in thread: Erann Gat: "Re: Progress report"
- Reply: Erann Gat: "Re: Progress report"
- Reply: Rahul Jain: "Re: Progress report"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|