@NotThreadSafe @CleanupObligation public final class IOCache extends Object implements Flushable, Closeable
cleared.
IOCache.Strategy, entry data written to the
cache may not be written to the backing store until the cache gets
flushed.
cleared.
| Modifier and Type | Class and Description |
|---|---|
private class |
IOCache.Buffer
A buffer for the contents of the cache.
|
private class |
IOCache.Input |
private class |
IOCache.InputBufferPool |
private class |
IOCache.Output |
private class |
IOCache.OutputBufferPool |
private static class |
IOCache.ProxyEntry
Used to proxy the backing store entries.
|
private static class |
IOCache.SocketFactory |
static class |
IOCache.Strategy
Provides different cache strategies.
|
private class |
IOCache.WriteBackOutputBufferPool |
private class |
IOCache.WriteThroughOutputBufferPool |
| Modifier and Type | Field and Description |
|---|---|
private IOCache.Buffer |
buffer |
private static IOCache.SocketFactory |
FACTORY |
private InputSocket<?> |
input |
private IOCache.InputBufferPool |
inputBufferPool |
private OutputSocket<?> |
output |
private IOCache.OutputBufferPool |
outputBufferPool |
private IOPool<?> |
pool |
private IOCache.Strategy |
strategy |
| Modifier | Constructor and Description |
|---|---|
private |
IOCache(IOCache.Strategy strategy,
IOPool<?> pool)
Constructs a new cache which applies the given caching strategy,
uses the given pool to allocate and release temporary I/O entries.
|
| Modifier and Type | Method and Description |
|---|---|
void |
clear()
Clears the entry data from this cache without flushing it.
|
void |
close()
|
IOCache |
configure(InputSocket<?> input)
Configures the input socket for reading the entry data from the
backing store.
|
IOCache |
configure(OutputSocket<?> output)
Configures the output socket for writing the entry data to the
backing store.
|
void |
flush()
Writes the cached entry data to the backing store unless already done.
|
private IOCache.Buffer |
getBuffer() |
Entry |
getEntry() |
private IOCache.InputBufferPool |
getInputBufferPool() |
InputSocket<?> |
getInputSocket()
Returns an input socket for reading the cached entry data.
|
private IOCache.OutputBufferPool |
getOutputBufferPool() |
OutputSocket<?> |
getOutputSocket()
Returns an output socket for writing the cached entry data.
|
private void |
setBuffer(IOCache.Buffer newBuffer) |
@CheckForNull private IOCache.Buffer buffer
private static final IOCache.SocketFactory FACTORY
@Nullable private InputSocket<?> input
@CheckForNull private IOCache.InputBufferPool inputBufferPool
@Nullable private OutputSocket<?> output
@CheckForNull private IOCache.OutputBufferPool outputBufferPool
private final IOPool<?> pool
private final IOCache.Strategy strategy
@CreatesObligation private IOCache(IOCache.Strategy strategy, IOPool<?> pool)
Note that you need to call configure(InputSocket) before
you can do any input.
Likewise, you need to call configure(OutputSocket) before
you can do any output.
strategy - the caching strategy.pool - the pool for allocating and releasing temporary I/O entries.public void clear()
throws IOException
IOException - on any I/O failure.@DischargesObligation public void close() throws IOException
close in interface Closeableclose in interface AutoCloseableIOExceptionpublic IOCache configure(InputSocket<?> input)
NullPointerException will be thrown on the first
read attempt.
Note that calling this method does not clear
this cache.input - an input socket for reading the entry data from the
backing store.thispublic IOCache configure(OutputSocket<?> output)
NullPointerException will be thrown on the first
write attempt.
Note that calling this method does not flush
this cache.output - an output socket for writing the entry data to the
backing store.thispublic void flush()
throws IOException
IOCache.Strategy.WRITE_THROUGH writes any
changed entry data immediately, so calling this method has no effect.flush in interface FlushableIOException@CheckForNull private IOCache.Buffer getBuffer()
private IOCache.InputBufferPool getInputBufferPool()
public InputSocket<?> getInputSocket()
private IOCache.OutputBufferPool getOutputBufferPool()
public OutputSocket<?> getOutputSocket()
private void setBuffer(@CheckForNull IOCache.Buffer newBuffer) throws IOException
IOExceptionCopyright © 2005-2012 Schlichtherle IT Services. All Rights Reserved.