db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Luciano Medina" <lmed...@tissat.es>
Subject Feedback on "Managers and Caching" reference page
Date Thu, 17 Aug 2006 10:22:06 GMT
Hello,

 

There is a mistake in the code samples of the "Managers and Caching"
reference page. It is on section "Invalidating the Cache":

 

public void addedObject(Persistent om)
{
    if (om instanceof Foo)
    {
        getMethodResult().removeAll(om, "getFoos");
    }
    else if (om instanceof X)
    {
        getMethodResult().remove(om, GET_URLS);
        getMethodResult().removeAll(om, GET_COMMENTS);
    }
    ...
}
 
The problem is the first parameter at the getMethodResult().removeAll and
getMethodResult().remove method calls. First, they will not compile because
om is a Persistent, while a Serializable is expected. Secondly, om is an
instance of Foo (in the first case), but we want to invalidate the cache for
Bar, so the appropriate Bar instance should be passed instead.

The correct code should be something like this:

 

public void addedObject(Persistent om)
{
    if (om instanceof Foo)
    {
        getMethodResult().removeAll(((Foo) om).getBar(), "getFoos");
    }
    ...
}
 
Actually, the if block must be surrounded with try/catch because
Foo.getBar() throws a TorqueException.

 

 

Luciano Medina



------------------------------------------------------------------------------------------------------------------------------------
Nota Legal: Este correo electronico puede contener informacion estrictamente confidencial
y es de uso exclusivo del destinatario, quedando prohibida a cualquier otra persona su revelacion,
copia, distribucion, o el ejercicio de cualquier accion relativa a su contenido. Si ha recibido
este correo electronico por error, por favor, conteste al remitente, y posteriormente proceda
a borrarlo de su sistema. Gracias por su colaboracion.

Confidentiality notice: This e-mail message may contain confidential and/or legally privileged
information and is solely for the attention and use of the intended recipient. Any disclosure,
copying, distribution or the taking of any action with relation to  the contents of this e-mail
by any other person is strictly prohibited. If you believe that this e-mail has been mistakenly
sent  to you, please reply to the sender from whom you received the message in error and then
delete the original e-mail from your system. Thank you for your co-operation.
------------------------------------------------------------------------------------------------------------------------------------


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message