commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Apache Wiki <>
Subject [Jakarta-commons Wiki] Update of "VfsCacheStrategy" by MarioIvankovits
Date Thu, 30 Mar 2006 19:38:05 GMT
Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Jakarta-commons Wiki" for change notification.

The following page has been changed by MarioIvankovits:

New page:
= VFS - CacheStragey =

One problem with libraries like vfs is that they cache some data to avoid successive access
to the real file - simply to speed up things.

This cache might get stale - no it GET stale.

Currently VFS provides three strategies to workaround it:

 * manual
 * on resolve (the default)
 * on call

Note: It is not possible to use {{{VFS.getManager}}} to configure the cacheStrategy. You have
to create your own static class to create it.

== manual cache strategy ==

StandardFileSystemManager fs = new StandardFileSystemManager();

using this setup you have to use {{{fileObject.refresh()}}} to refresh your object with the

== on_resolve ==

StandardFileSystemManager fs = new StandardFileSystemManager();

every time you call {{{fs.resolveFile()}}} the file data will be refreshed. You still can
use {{{fileObject.refresh()}}} to refresh the data on demand.

== on_call ==

StandardFileSystemManager fs = new StandardFileSystemManager();

Every time you call a method on the resolve file object the data will be refreshed with the
filesystem. This will give you the behaviour you might expect from a local file but also might
be a hughe performance loss as it will greatly increase the network load.

You also can archive this cache strategy if you pack the file object in an {{{org.apache.commons.vfs.cache.OnCallRefreshFileObject}}}

FileObject fo = VFS.getManager().resolveFile("....");
OnCallRefreshFileObject foc = new OnCallRefreshFileObject(fo);

the difference to the above is, that in the first case you will always get the same file object
instance and thus you can synchronize against it.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message