@ThreadSafe @DefaultAnnotation(value=edu.umd.cs.findbugs.annotations.NonNull.class) 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 |
private static class |
IOCache.BufferSocketFactory |
private static class |
IOCache.CacheEntry
Hides backing store entries.
|
private class |
IOCache.Input |
private class |
IOCache.InputBufferPool |
private static class |
IOCache.Lock |
private class |
IOCache.Output |
private class |
IOCache.OutputBufferPool |
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.BufferSocketFactory |
FACTORY |
private InputSocket<?> |
input |
private IOCache.InputBufferPool |
inputBufferPool |
private IOCache.Lock |
lock |
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
and uses the given pool to allocate and release temporary I/O entries.
|
| Modifier and Type | Method and Description |
|---|---|
void |
clear()
Discards the entry data in this buffer.
|
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 volatile IOCache.Buffer buffer
private static final IOCache.BufferSocketFactory FACTORY
@Nullable private volatile InputSocket<?> input
@CheckForNull private volatile IOCache.InputBufferPool inputBufferPool
private final IOCache.Lock lock
@Nullable private volatile OutputSocket<?> output
@CheckForNull private volatile IOCache.OutputBufferPool outputBufferPool
private final IOPool<?> pool
private final IOCache.Strategy strategy
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
IOExceptionpublic 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 © 2004-2011 Schlichtherle IT Services. All Rights Reserved.