RE: Barracuda -- caching

"Christian Cryder" <[email protected]>
Newsgroups gmane.comp.java.enhydra.barracuda.general
Message-ID <[email protected]>
And in answer to your second question...

> - does Barracuda provide facilities to monitor the size of the cache?

No it currently doesn't. The caching we use is really just a veneer on top
of the JDK's Soft/Weak cache mechanism, meaning we really leave it up to the
JDK when to reclaim cache objects.

That said, you can remove them manually yourself (we do this when a user
logs out, or changes certain settings for instance that would render any
cached information stale). One of the slick things about Barracuda's
ObjectRepository stuff is that you can a) get a list of items in cache, and
b) you can remove items from cache using a wildcard.

We put things in via class name + key name. For instance, lets say I have
SomeReport class that sticks multiple things into the cache:

public class SomeReport {
    private static final Class CLASS = SomeReport.class;

    ...

    //repository keys
    protected static final String REPORT_LIST = CLASS+".ReportList";
    protected static final String CUSTOM_CMD = CLASS+".CustomCmd";
    protected static final String REPORT_FORM = CLASS+".ReportForm";
    protected static final String REPORT_ERR = CLASS+".ReportErr";

    ...

    public void doSomethingThatStoresInCache() {
        ...
        ObjectRepository cache =
ObjectRepository.getSoftSessionRepository();
        cache.putState(REPORT_LIST, rptlist);
        cache.putState(REPORT_FORM, rptform);
        ...
    }

    public void doSomethingThatMakesCacheStale() {
        ...
        ObjectRepository cache =
ObjectRepository.getSoftSessionRepository();
        cache.removeState(CLASS.getName()+"*");
        ...
    }
}

That removeState() with a wildcard on the end will remove anything related
to this class from the cache. Now, this is not as flexible as it could be
(ie. wildcard support is very minimal; we don't support reg expressions,
etc), but it works quite well for our needs, and if you needed something
more robust it'd be pretty easy to implement.

That help at all?
Christian

----------------------------------------------
Christian Cryder
Internet Architect, ATMReports.com
Project Chair, BarracudaMVC - http://barracudamvc.org
----------------------------------------------
"Coffee? I could quit anytime, just not today"


> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]]On Behalf Of Canavaggio
> Guillaume ZFF PA-K
> Sent: Monday, October 27, 2003 10:45 AM
> To: '[email protected]'
> Subject: [Barracuda] Barracuda -- caching
>
>
> Hello,
>
> I was wondering whether Barracuda provides a caching mechanism or not.
>
> If the answer is positive:
> - is Barracuda's cache a special-purpose or a general-purpose cache?
> - does Barracuda provide facilities to monitor the size of the cache?
>
> Mit freundlichen Gruessen
>
> Guillaume Canavaggio
>
> Informatik Vorentwicklung (IV) / Advance IT Development
> ZF Friedrichshafen AG, D-88038 Friedrichshafen, Germany
> Tel.: +49 / 0/ 7541 77- 3950
>
> _______________________________________________
> Barracuda mailing list
> [email protected]
> http://barracudamvc.org/lists/listinfo/barracuda
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.