clearing the cache on a onetomany setup

1 view
Skip to first unread message

mark mazelin

unread,
Jun 11, 2008, 10:17:59 AM6/11/08
to transfer-dev
I have a one to many relationship set in my transfer.xml between a
user object and one or more payments. It is set to use an array
collection of payments. The problem I'm running it to is that the user
and payment records get created, then an outside application handles
the actual payment,updates the payment record (through a direct SQL
call) and redirects back to this app. With the default transfer
caching, my payment record is cached with the old information and
doesn't see the updated data. I would like to clear the cache for just
the payments for that user when control returns from the payment
processing, but I'm not quite sure of the syntax to do that. One
thought was to do something like this:

<cfset transfer.discardByClassAndKey("myapp.payment",
payment.getPaymentId())>

but then I wasn't certain how to proceed to actually refresh the
payment array in the user object. Do I just call the
user.getPaymentArray() again? Is this the proper way to proceed, or is
there a better way to handle this situation? Is there a way to clear
the entire payment array cache in the user object? Or am I
misunderstanding the level at which caching occurs.

Still learning how to handle the caching...

Mark Mandel

unread,
Jun 11, 2008, 7:22:25 PM6/11/08
to transf...@googlegroups.com
Mark,

(That was confusing, i thought I was emailing the list! ;o) )

If you discard an object from the cache, it will automatically handle
it in regards to compositions. So if you discard the payment, the
user object should go along with it.

(That being said, I worry about your User object, in that, how many
payments do you expect to have with a user, could end up being pretty
big, which could be pretty slow).

Mark

--
E: mark....@gmail.com
W: www.compoundtheory.com

Mark Mazelin

unread,
Jun 12, 2008, 5:15:42 PM6/12/08
to transf...@googlegroups.com
Mark:

Yeah, too many "Mark M."'s around, eh?

Given your comment, I just discarded the main user object and the payments went with it. I wish I could have just discarded the payments and kept the other connections intact (their are several other relationships), but this will work for now. By the way, their will typically only be one payment, but may involve several, so bloatedness shouldn't be an issue. Having said that though, is there a better way to handle the relationships? I enjoy being able to call getPaymentArray() and looping through them...

Mark Mazelin

Mark Mandel

unread,
Jun 12, 2008, 7:27:55 PM6/12/08
to transf...@googlegroups.com
Unfortunately, there is no 'better' way - there is only the way that
will be good for your application, and has the right benefits for your
application.

There is no silver bullet ;o) so you'll just have to make intelligent
decisions :oD
(Which is tricky for me right now, considering how much I drank last
night at the webDU bowling/laser tag)

Mark

Reply all
Reply to author
Forward
0 new messages