Hi Thomas,
though I have no experience with the Cache, the code looks good to me.
Thomas
Thomas Vandahl <[EMAIL PROTECTED]> schrieb am 08.09.2005 16:31:16:
> Thomas Vandahl wrote:
> > Not without bigger changes in the AbstractBaseManager. I will have a
> > look at this. I guess the real fun starts if I want to cache the whole
> > collection of books at once (using MethodResultCache for example, not
to
> > speak of invalidation).
>
> Replying to myself is fun...
>
> Well, I finally came up with an attempt for a solution. It was less work
> than I expected, but I guess we are only halfway through. It passes the
> runtime test, however.
>
> It looks like this:
> ---8<---
> public Author getAuthor(Connection connection)
> throws TorqueException
> {
> if (aAuthor == null && (this.authorId != 0))
> {
> aAuthor =
> AuthorManager.getCachedInstance(SimpleKey.keyFor(this.authorId));
> if (aAuthor == null)
> {
> aAuthor =
> AuthorPeer.retrieveByPK(SimpleKey.keyFor(this.authorId), connection);
> AuthorManager.putInstance(aAuthor);
> }
> }
> return aAuthor;
> }
> ---8<---
>
> While I was at it I corrected a few problems PMD complained about, but
> there is still room for improvement... :-)
>
> Any comments are welcome.
>
> Bye, Thomas.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]