org.sapia.filestorm.file
Class CachingFileStore
java.lang.Object
org.sapia.filestorm.file.FileStore
org.sapia.filestorm.file.CachingFileStore
- All Implemented Interfaces:
- Store
public class CachingFileStore
- extends FileStore
An instance of this class implements caching over another Store
- the other store acts as a master copy.
An instance of this class uses the local file system to keep cached data. That cached
data is synchronized with the delegate store after a given period of time.
- Author:
- yduchesne
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
CachingFileStore
public CachingFileStore(File baseDir,
Store delegate,
long timeout,
int bufSize)
throws IOException
- Parameters:
baseDir - the base directory of this instance.delegate - the delegate Store - with which this instance's state
is to be synchronized.timeout - the timeout after which given data is to be synchronized with the
delegate instance.bufSize - the size of buffers that are internally used for data transfer.
- Throws:
IOException - if an IO problem occurs when creating the instance.
get
public InputStream get(String name)
throws IOException
- Specified by:
get in interface Store- Overrides:
get in class FileStore
- Parameters:
name - the name corresponding to the data to retrieve.
- Returns:
- the stream of data corresponding to the given name.
- Throws:
IOException - if an IO problem occurs while performing this operation.
FileNotFoundException - if no data exists for the given name.
get
public void get(String name,
OutputStream out)
throws FileNotFoundException,
IOException
- Description copied from interface:
Store
- Streams the data corresponding to the given name into the given stream.
The stream is closed by this method.
- Specified by:
get in interface Store- Overrides:
get in class FileStore
- Parameters:
name - the name corresponding to the data to retrieve.out - an OutputStream to which the data is to be written.
- Throws:
FileNotFoundException - if no data exists for the given name.
IOException - if an IO problem occurs while performing this operation.
contains
public boolean contains(String name)
throws IOException
- Specified by:
contains in interface Store- Overrides:
contains in class FileStore
- Parameters:
name - the name corresponding to the data whose existence must be checked.
- Returns:
- true if data exists for the given name, false otherwise.
- Throws:
IOException
close
public void close()
- Description copied from interface:
Store
- Closes this instance.
- Specified by:
close in interface Store- Overrides:
close in class FileStore
notifyUpdate
public void notifyUpdate(String name)
notifyDelete
public void notifyDelete(String name)
Copyright © 2007 Sapia Open Community, Inc. All Rights Reserved.