Title: AW: AW: How to make Generator cacheable?

Ok, I see.

Here is my new code:

public Serializable getKey() {

        return objekt+objekt_ID+geb_ID+stock_ID+abweichungen+suchtyp;

        }

public SourceValidity getValidity() {

        try {

        TaminoClient tc = new                                                           TaminoClient("http://localhost/tamino/BSDB30032005/Hessen");

        tc.setSAXimplementer("com.jclark.xml.sax.Driver");

        String query = "/[EMAIL PROTECTED]"+geb_ID+"]";

        TaminoResult tr = tc.query(query);

        long lastModified = tr.getLastModified().getTime();

        System.out.println("Letzte Aenderung: "+lastModified);

        TimeStampValidity timeStamp = new TimeStampValidity(lastModified);

        return timeStamp;

        } catch (TaminoError e) {

                e.printStackTrace();

                return null;

        }

}


If this is he correct why, I have another problem: the line tr.getLastModified().getTime(); always returns 0. But I don't know why.

Can anybody help?


Thanks,

Barthi


> -----Ursprüngliche Nachricht-----

> Von: g[R]eK [mailto:[EMAIL PROTECTED]]

> Gesendet: Sonntag, 15. Januar 2006 22:01

> An: [email protected]

> Betreff: Re: AW: How to make Generator cacheable?

>

> Christian Barth napisał(a):

> > The caching is working now with the following code

> > <snip/>

> > But as you can see, The Cache expires after 5 minutes. What I want is,

> that

> > is gets invalid, when the LastModificationDate of my DB has changed.

> >

> > In the getKey()-Method I have already searialized the timestamp of the

> last

> > modification, But now I don't know how to test, if the Cache is still

> valid

> > in the getValidity()-Method.

> >

> > Can anybody help?

> I think you confuse things about caching. The key of cache should not be

> a timestamp. The key is unique identifier of your particular

> configuration (e.g. your database url), and validity object contains

> information needed to check if entry with particular key is still valid.

> In your case, you can return whatever you want in your getKey() method

> (if you have only i configuration). The getValidity() should return

> TimeStampValidity[1].

>

> Check [2] for further information. Hope this helps.

>

> [1]

> http://excalibur.apache.org/apidocs/org/apache/excalibur/source/impl/valid

> ity/TimeStampValidity.html

> [2] http://cocoon.zones.apache.org/daisy/documentation/writing/690.html