To reduce contention, entry allocation and eviction execute in a sampling fashion (entry hits modulo N). Eviction follows an LRU approach (oldest sampled entries are removed first) when the cache is out of capacity
In order to expedite reclamation, cache entries are reference counted as opposed to garbage collected.
| Modifier and Type | Class and Description |
|---|---|
| public static class |
| Modifier and Type | Field and Description |
|---|---|
| private final ConcurrentDirectDeque | |
| private final ConcurrentMap | |
| private final int | |
| private final LimitedBufferSlicePool | |
| private static final int | |
| private final int |
| Access | Constructor and Description |
|---|---|
| public | |
| public | DirectBufferCache(int sliceSize, int slicesPerPage, int maxMemory, final BufferAllocator<ByteBuffer> bufferAllocator)
|
| public | DirectBufferCache(int sliceSize, int slicesPerPage, int maxMemory, final BufferAllocator<ByteBuffer> bufferAllocator, int maxAge)
|
| Modifier and Type | Method and Description |
|---|---|
| public DirectBufferCache. | |
| public DirectBufferCache. | |
| private void | |
| public DirectBufferCache. | |
| public Set | |
| public void |
| accessQueue | back to summary |
|---|---|
| private final ConcurrentDirectDeque<DirectBufferCache. | |
| cache | back to summary |
|---|---|
| private final ConcurrentMap<Object, DirectBufferCache. | |
| maxAge | back to summary |
|---|---|
| private final int maxAge | |
| pool | back to summary |
|---|---|
| private final LimitedBufferSlicePool pool | |
| SAMPLE_INTERVAL | back to summary |
|---|---|
| private static final int SAMPLE_INTERVAL | |
| sliceSize | back to summary |
|---|---|
| private final int sliceSize | |
| DirectBufferCache | back to summary |
|---|---|
| public DirectBufferCache(int sliceSize, int slicesPerPage, int maxMemory) | |
| DirectBufferCache | back to summary |
|---|---|
| public DirectBufferCache(int sliceSize, int slicesPerPage, int maxMemory, final BufferAllocator<ByteBuffer> bufferAllocator) | |
| DirectBufferCache | back to summary |
|---|---|
| public DirectBufferCache(int sliceSize, int slicesPerPage, int maxMemory, final BufferAllocator<ByteBuffer> bufferAllocator, int maxAge) | |
| add | back to summary |
|---|---|
| public DirectBufferCache. | |
| add | back to summary |
|---|---|
| public DirectBufferCache. | |
| bumpAccess | back to summary |
|---|---|
| private void bumpAccess(DirectBufferCache. | |
| get | back to summary |
|---|---|
| public DirectBufferCache. | |
| getAllKeys | back to summary |
|---|---|
| public Set Returns a set of all the keys in the cache. This is a copy of the key set at the time of method invocation. | |
| remove | back to summary |
|---|---|
| public void remove(Object key) | |
| Modifier and Type | Field and Description |
|---|---|
| private volatile Object | |
| private volatile LimitedBufferSlicePool. | |
| private static final AtomicReferenceFieldUpdater | |
| private final DirectBufferCache | |
| private static final Object | |
| private static final LimitedBufferSlicePool. | |
| private volatile int | |
| private static final AtomicIntegerFieldUpdater | |
| private volatile long | |
| private volatile int | |
| private static final AtomicIntegerFieldUpdater | |
| private static final LimitedBufferSlicePool. | |
| private final Object | |
| private final int | |
| private volatile int | |
| private static final AtomicIntegerFieldUpdater | |
| private final int | |
| private static final AtomicReferenceFieldUpdater |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | |
| public LimitedBufferSlicePool. | |
| public boolean | |
| pack-priv Object | |
| pack-priv Object | |
| public boolean | |
| private void | |
| public void | |
| public void | |
| public boolean | |
| pack-priv long | |
| public int | |
| public Object | |
| public boolean | |
| pack-priv boolean | |
| public int |
| accessToken | back to summary |
|---|---|
| private volatile Object accessToken | |
| buffers | back to summary |
|---|---|
| private volatile LimitedBufferSlicePool. | |
| bufsUpdater | back to summary |
|---|---|
| private static final AtomicReferenceFieldUpdater<DirectBufferCache. | |
| cache | back to summary |
|---|---|
| private final DirectBufferCache cache | |
| CLAIM_TOKEN | back to summary |
|---|---|
| private static final Object CLAIM_TOKEN | |
| EMPTY_BUFFERS | back to summary |
|---|---|
| private static final LimitedBufferSlicePool. | |
| enabled | back to summary |
|---|---|
| private volatile int enabled | |
| enabledUpdator | back to summary |
|---|---|
| private static final AtomicIntegerFieldUpdater<DirectBufferCache. | |
| expires | back to summary |
|---|---|
| private volatile long expires | |
| hits | back to summary |
|---|---|
| private volatile int hits | |
| hitsUpdater | back to summary |
|---|---|
| private static final AtomicIntegerFieldUpdater<DirectBufferCache. | |
| INIT_BUFFERS | back to summary |
|---|---|
| private static final LimitedBufferSlicePool. | |
| key | back to summary |
|---|---|
| private final Object key | |
| maxAge | back to summary |
|---|---|
| private final int maxAge | |
| refs | back to summary |
|---|---|
| private volatile int refs | |
| refsUpdater | back to summary |
|---|---|
| private static final AtomicIntegerFieldUpdater<DirectBufferCache. | |
| size | back to summary |
|---|---|
| private final int size | |
| tokenUpdator | back to summary |
|---|---|
| private static final AtomicReferenceFieldUpdater<DirectBufferCache. | |
| CacheEntry | back to summary |
|---|---|
| private CacheEntry(Object key, int size, DirectBufferCache cache, final int maxAge) | |
| allocate | back to summary |
|---|---|
| public boolean allocate() | |
| buffers | back to summary |
|---|---|
| public LimitedBufferSlicePool. | |
| claimEnable | back to summary |
|---|---|
| public boolean claimEnable() | |
| claimToken | back to summary |
|---|---|
| pack-priv Object claimToken() | |
| clearToken | back to summary |
|---|---|
| pack-priv Object clearToken() | |
| dereference | back to summary |
|---|---|
| public boolean dereference() | |
| destroy | back to summary |
|---|---|
| private void destroy() | |
| disable | back to summary |
|---|---|
| public void disable() | |
| enable | back to summary |
|---|---|
| public void enable() | |
| enabled | back to summary |
|---|---|
| public boolean enabled() | |
| getExpires | back to summary |
|---|---|
| pack-priv long getExpires() | |
| hit | back to summary |
|---|---|
| public int hit() | |
| key | back to summary |
|---|---|
| public Object key() | |
| reference | back to summary |
|---|---|
| public boolean reference() | |
| setToken | back to summary |
|---|---|
| pack-priv boolean setToken(Object token) | |
| size | back to summary |
|---|---|
| public int size() | |