public abstract class AsynchronousFileCacheBacking extends AbstractIndexedFileCacheBacking
AsynchronousFileCacheBacking.AsyncCommands
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.AbstractCommands 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_FILEWEAVED_CLASS_CACHE_DIRlogger| Modifier | Constructor and Description |
|---|---|
protected |
AsynchronousFileCacheBacking(java.io.File cacheDir) |
createIndexEntry, getIndexFile, getKeys, readIndex, readIndex, readIndex, resolveIndexMapEntry, writeIndex, writeIndex, writeIndex, writeIndex, writeIndexclose, close, delete, getCacheDirectory, writeClassBytescrcprotected 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 AbstractIndexedFileCacheBackingpublic CachedClassEntry get(CachedClassReference ref, byte[] originalBytes)
CacheBackingref - 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)
CacheBackingentry - 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)
CacheBackingprotected 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()
CacheBackingprotected void executeCommand(AsynchronousFileCacheBacking.AsyncCommand cmd) throws java.lang.Exception
java.lang.Exceptionprotected void executeClearCommand()
throws java.lang.Exception
java.lang.Exceptionprotected void executeUpdateIndexCommand()
throws java.lang.Exception
java.lang.Exceptionprotected void executeInsertCommand(AsynchronousFileCacheBacking.InsertCommand cmd) throws java.lang.Exception
java.lang.Exceptionprotected void executeRemoveCommand(AsynchronousFileCacheBacking.RemoveCommand cmd) throws java.lang.Exception
java.lang.Exceptionprotected 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.Objectprotected static final <T extends AsynchronousFileCacheBacking> T createBacking(java.io.File cacheDir, AsynchronousFileCacheBacking.AsynchronousFileCacheBackingCreator<T> creator)
public static final boolean postCacheCommand(AsynchronousFileCacheBacking.AsyncCommand cmd)