Transfer Cache, shared objects and concurrency

1 view
Skip to first unread message

achebe

unread,
Nov 6, 2009, 12:05:03 PM11/6/09
to transfer-dev
I have a SQL based ACL system that I'm using in my tranfser based
application. I have left the caching at the default of "instance".
Each of my access controlled transfer objects has a permits() method
that runs a query against the databse each time it is called, so in my
code I say things like:

if(theTO.permits('WRITE'){
transfer.save(theTO);
}

I'd like to be able to cache the results of that query in my transfer
object so that I don't have to go to the database every time I want to
check the permission. I was thinking I could use a lastAccessedBy
variable in the variables scope of my TO that checked to see if the
user currently calling the permits() method is the same one as the
last person who called the permits() method so that I could use the
cached results instead of running the query again. The thing I'm
worried about is concurrency, how can I be absolutely sure that the
lastAccessedBy value is correct when pulling a TO out of the cache?

Mark Mandel

unread,
Nov 6, 2009, 3:20:17 PM11/6/09
to transf...@googlegroups.com
This doesn't really seem like a transfer question - but why not store the result based on the user id inside the object?

That way you only ever retrieve the cached result for that user?

Mark
--
E: mark....@gmail.com
T: http://www.twitter.com/neurotic
W: www.compoundtheory.com

Chris Teachworth

unread,
Nov 6, 2009, 3:43:32 PM11/6/09
to transf...@googlegroups.com
Duh. Thanks Mark, sometimes I can't see the forest for the trees.
Reply all
Reply to author
Forward
0 new messages