public abstract class AsynchronousFileCacheBacking extends AbstractIndexedFileCacheBacking
AsynchronousFileCacheBacking.AsyncCommand
s
to signal to a background thread various actions required to "synchronize"
the in-memory cache with the persisted copy. Whenever there is a cache miss
from the #get(CachedClassReference)
call, the weaver issues a
#put(CachedClassEntry)
call. This call has 2 side-effects:
#get(CachedClassReference)
will not return the mapped value.
AsynchronousFileCacheBacking.AsyncCommand
is posted to the background
thread so that the newly mapped value will be persisted (eventually)
Modifier and Type | Class and Description |
---|---|
static class |
AsynchronousFileCacheBacking.AbstractCommand |
static interface |
AsynchronousFileCacheBacking.AsyncCommand
Represents an asynchronous command that can be sent to the
AsynchronousFileCacheBacking instance to be executed
on it asynchronously |
static interface |
AsynchronousFileCacheBacking.AsynchronousFileCacheBackingCreator<T extends AsynchronousFileCacheBacking> |
static class |
AsynchronousFileCacheBacking.ClearCommand |
static class |
AsynchronousFileCacheBacking.InsertCommand |
static class |
AsynchronousFileCacheBacking.KeyedCommand
Base class for
AsynchronousFileCacheBacking.AbstractCommand s that refer to a cache key |
static class |
AsynchronousFileCacheBacking.RemoveCommand |
static class |
AsynchronousFileCacheBacking.UpdateIndexCommand |
AbstractIndexedFileCacheBacking.IndexEntry
Modifier and Type | Field and Description |
---|---|
protected java.util.Map<java.lang.String,byte[]> |
bytesMap |
protected java.util.Map<java.lang.String,byte[]> |
exposedBytes |
protected java.util.Map<java.lang.String,AbstractIndexedFileCacheBacking.IndexEntry> |
exposedIndex |
protected java.util.Map<java.lang.String,AbstractIndexedFileCacheBacking.IndexEntry> |
index |
EMPTY_INDEX, EMPTY_KEYS, INDEX_FILE
WEAVED_CLASS_CACHE_DIR
logger
Modifier | Constructor and Description |
---|---|
protected |
AsynchronousFileCacheBacking(java.io.File cacheDir) |
createIndexEntry, getIndexFile, getKeys, readIndex, readIndex, readIndex, resolveIndexMapEntry, writeIndex, writeIndex, writeIndex, writeIndex, writeIndex
close, close, delete, getCacheDirectory, writeClassBytes
crc
protected final java.util.Map<java.lang.String,AbstractIndexedFileCacheBacking.IndexEntry> index
protected final java.util.Map<java.lang.String,AbstractIndexedFileCacheBacking.IndexEntry> exposedIndex
protected final java.util.Map<java.lang.String,byte[]> bytesMap
protected final java.util.Map<java.lang.String,byte[]> exposedBytes
protected AsynchronousFileCacheBacking(java.io.File cacheDir)
protected java.util.Map<java.lang.String,AbstractIndexedFileCacheBacking.IndexEntry> getIndex()
getIndex
in class AbstractIndexedFileCacheBacking
public CachedClassEntry get(CachedClassReference ref, byte[] originalBytes)
CacheBacking
ref
- entry to retrieveoriginalBytes
- Pre-weaving class bytes - required in order to
ensure that the cached entry refers to the same original classpublic void put(CachedClassEntry entry, byte[] originalBytes)
CacheBacking
entry
- key of the entryoriginalBytes
- Pre-weaving class bytes - required in order to
ensure that the cached entry refers to the same original classpublic void remove(CachedClassReference ref)
CacheBacking
protected AbstractIndexedFileCacheBacking.IndexEntry remove(java.lang.String key)
public java.util.List<AbstractIndexedFileCacheBacking.IndexEntry> getIndexEntries()
public java.util.Map<java.lang.String,AbstractIndexedFileCacheBacking.IndexEntry> getIndexMap()
public java.util.Map<java.lang.String,byte[]> getBytesMap()
public void clear()
CacheBacking
protected void executeCommand(AsynchronousFileCacheBacking.AsyncCommand cmd) throws java.lang.Exception
java.lang.Exception
protected void executeClearCommand() throws java.lang.Exception
java.lang.Exception
protected void executeUpdateIndexCommand() throws java.lang.Exception
java.lang.Exception
protected void executeInsertCommand(AsynchronousFileCacheBacking.InsertCommand cmd) throws java.lang.Exception
java.lang.Exception
protected void executeRemoveCommand(AsynchronousFileCacheBacking.RemoveCommand cmd) throws java.lang.Exception
java.lang.Exception
protected abstract void removeClassBytes(java.lang.String key) throws java.lang.Exception
executeRemoveCommand(RemoveCommand)
key
- The key representing the class whose bytes are to be removedjava.lang.Exception
- if failed to remove class bytesprotected abstract java.util.Map<java.lang.String,byte[]> readClassBytes(java.util.Map<java.lang.String,AbstractIndexedFileCacheBacking.IndexEntry> indexMap, java.io.File cacheDir)
public java.lang.String toString()
toString
in class java.lang.Object
protected static final <T extends AsynchronousFileCacheBacking> T createBacking(java.io.File cacheDir, AsynchronousFileCacheBacking.AsynchronousFileCacheBackingCreator<T> creator)
public static final boolean postCacheCommand(AsynchronousFileCacheBacking.AsyncCommand cmd)