|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object
|
+--com.caucho.vfs.Path
|
+--com.caucho.vfs.FilesystemPath
|
+--com.caucho.vfs.CachePath
A cache wrapper over a path. All files are automatically cached.
Once the cache is created, you use the file just like any other Path:
Path root = new CachePath(Vfs.lookup("test/cacheable"));
ReadStream is = root.lookup("test.file").openRead();
...
is.close();
The cache size is governed by two limits: memory size and number of entries. The size of the disk is considered infinite, and it limited only by the number of entries.
The cache entries are stored in an LRU with a capacity of the number of entries. If loading a new file pushes the memory size over the limit, the old files are dropped from the memory cache.
| Fields inherited from class com.caucho.vfs.FilesystemPath |
bindRoot, pathname, root, separatorChar, userPath |
| Fields inherited from class com.caucho.vfs.Path |
L, schemeMap |
| Constructor Summary | |
protected |
CachePath(FilesystemPath root,
java.lang.String userPath,
java.lang.String path)
Internal creation of a path for the vfs. |
|
CachePath(Path root,
int entries,
long capacity)
Creates a new cache. |
| Method Summary | |
boolean |
canRead()
Tests if the file can be read. |
boolean |
canWrite()
Tests if the file can be written. |
void |
clear()
Clear the memory cache. |
boolean |
equals(java.lang.Object b)
|
boolean |
exists()
Returns true if the underlying file exists. |
protected Path |
fsWalk(java.lang.String userPath,
java.util.Map attributes,
java.lang.String path)
Looks up the cache entry for a given path. |
long |
getLastModified()
Returns the last modified time of the file. |
long |
getLength()
Returns the length of the file in bytes. |
java.lang.String |
getScheme()
The scheme for the path is cache: |
int |
hashCode()
Returns the hash code, which is based on the underlying file. |
boolean |
isDirectory()
Tests if the path refers to a directory. |
boolean |
isFile()
Tests if the path refers to a file. |
java.lang.String[] |
list()
|
boolean |
mkdir()
Creates the directory named by this path. |
boolean |
mkdirs()
Creates the directory named by this path and any parent directories. |
StreamImpl |
openAppendImpl()
|
StreamImpl |
openReadImpl()
Opens a read stream to the path. |
StreamImpl |
openReadWriteImpl()
|
StreamImpl |
openWriteImpl()
|
boolean |
remove()
Removes the file or directory named by this path. |
boolean |
renameTo(Path path)
Renames the file or directory to the name given by the path. |
void |
setLastModified(long time)
|
void |
setRemoveOnRelease(boolean remove)
If set, files bumped from the cache are removed from the underlying filesystem. |
void |
writeToStream(java.io.OutputStream os)
Write the contents of the cache item to the output stream. |
| Methods inherited from class com.caucho.vfs.FilesystemPath |
bind, copy, createRoot, getFullPath, getParent, getPath, getTail, getURL, getUserPath, normalizePath, normalizePath, schemeWalk, setUserPath, toString |
| Methods inherited from class com.caucho.vfs.Path |
createNewFile, createRoot, createTempFile, getAttribute, getAttributeNames, getContentType, getHost, getNativePath, getObject, getPort, getQuery, getResources, getResources, getValue, isObject, iterator, lookup, lookup, lookupNative, lookupNative, openAppend, openRead, openReadWrite, openReadWrite, openWrite, removeAttribute, renameTo, scanScheme, setAttribute, setObject, setValue, unbind |
| Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
public CachePath(Path root,
int entries,
long capacity)
root - underlying backing store.entries - the number of entries in the cache.capacity - total size in bytes allowed in the memory cache.
protected CachePath(FilesystemPath root,
java.lang.String userPath,
java.lang.String path)
root - the root path (i.e. the cache root)userPath - the path the application used in the lookuppath - canonical path| Method Detail |
public void setRemoveOnRelease(boolean remove)
remove - if true, remove the underlying file on a release.
protected Path fsWalk(java.lang.String userPath,
java.util.Map attributes,
java.lang.String path)
fsWalk in class FilesystemPathuserPath - the string given by the user in lookup()attributes - the user's initialization attributespath - the canonical path namepublic java.lang.String getScheme()
getScheme in class Pathpublic void clear()
public boolean exists()
exists in class Pathpublic boolean isDirectory()
PathisDirectory in class Pathpublic boolean isFile()
PathisFile in class Pathpublic long getLength()
PathgetLength in class Pathcom.caucho.vfs.Pathpublic long getLastModified()
PathgetLastModified in class Pathcom.caucho.vfs.Pathpublic void setLastModified(long time)
setLastModified in class Pathpublic boolean canRead()
PathcanRead in class Pathpublic boolean canWrite()
PathcanWrite in class Path
public java.lang.String[] list()
throws java.io.IOException
list in class Pathcom.caucho.vfs.Path
public boolean mkdir()
throws java.io.IOException
Pathmkdir in class Pathcom.caucho.vfs.Path
public boolean mkdirs()
throws java.io.IOException
Pathmkdirs in class Pathcom.caucho.vfs.Path
public boolean remove()
throws java.io.IOException
Pathremove in class Pathcom.caucho.vfs.Path
public boolean renameTo(Path path)
throws java.io.IOException
PathrenameTo in class Pathcom.caucho.vfs.Path
public void writeToStream(java.io.OutputStream os)
throws java.io.IOException
writeToStream in class Pathos - destination output stream.
public StreamImpl openReadImpl()
throws java.io.IOException
openReadImpl in class Path
public StreamImpl openWriteImpl()
throws java.io.IOException
openWriteImpl in class Path
public StreamImpl openAppendImpl()
throws java.io.IOException
openAppendImpl in class Path
public StreamImpl openReadWriteImpl()
throws java.io.IOException
openReadWriteImpl in class Pathpublic int hashCode()
hashCode in class FilesystemPathpublic boolean equals(java.lang.Object b)
equals in class FilesystemPath
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||