Interface OOCCacheScheduler
- All Known Implementing Classes:
OOCLRUCacheScheduler
public interface OOCCacheScheduler
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionvoidaddReference(BlockKey key) Notifies the cache that there is another reference to the same block key.voidForgets a block from the cache.longReturns the current cache size in bytes.longReturns the hard cache limit in bytes.longReturns the number of pinned bytes in the cache.handover(BlockKey key, InMemoryQueueCallback callback) booleanReturns if the current cache size is within its defined memory limits.booleanReturns if the current cache size is within its soft memory limits.voidpin(BlockEntry entry) Pins a BlockEntry in cache to prevent eviction.voidprioritize(BlockKey key, double priority) Adds the given priority to any pending request accessing the key.Places a new block in the cache.Places a new block in the cache and returns a pinned handle.putAndPinSourceBacked(BlockKey key, Object data, long size, OOCIOHandler.SourceBlockDescriptor descriptor) Places a new source-backed block in the cache and returns a pinned handle.voidputSourceBacked(BlockKey key, Object data, long size, OOCIOHandler.SourceBlockDescriptor descriptor) Places a new source-backed block in the cache and registers the location with the IO handler.Requests a list of blocks from the cache that must be available at the same time.Requests a single block from the cache.requestAnyOf(List<BlockKey> keys, int n, List<BlockKey> selectionOut) Requests any n entries of the list of blocks, preferring an available item.voidshutdown()Shuts down the cache scheduler.snapshot()Creates a snapshot of the cache.tryRequest(List<BlockKey> keys) Tries to request a list of blocks from the cache that must be available at the same time.default BlockEntrytryRequest(BlockKey key) Tries to request a single block from the cache.tryRequestAnyOf(List<BlockKey> keys, int n, List<BlockKey> selectionOut) Requests any n entries of the list of blocks, preferring an available item.voidunpin(BlockEntry entry) Unpins a pinned block.voidupdateLimits(long evictionLimit, long hardLimit) Updates the cache limits.
-
Method Details
-
request
Requests a single block from the cache.- Parameters:
key- the requested key associated to the block- Returns:
- the available BlockEntry
-
tryRequest
Tries to request a single block from the cache. Immediately returns the entry if present, otherwise null without scheduling reads.- Parameters:
key- the requested key associated to the block- Returns:
- the available BlockEntry or null
-
request
Requests a list of blocks from the cache that must be available at the same time.- Parameters:
keys- the requested keys associated to the block- Returns:
- the list of available BlockEntries
-
tryRequest
Tries to request a list of blocks from the cache that must be available at the same time. Immediately returns the list of entries if present, otherwise null without scheduling reads.- Parameters:
keys- the requested keys associated to the block- Returns:
- the list of available BlockEntries
-
requestAnyOf
CompletableFuture<List<BlockEntry>> requestAnyOf(List<BlockKey> keys, int n, List<BlockKey> selectionOut) Requests any n entries of the list of blocks, preferring an available item. -
tryRequestAnyOf
Requests any n entries of the list of blocks, preferring an available item. -
prioritize
Adds the given priority to any pending request accessing the key. Multi-requests are prioritized partially. -
put
Places a new block in the cache. Note that objects are immutable and cannot be overwritten. The object data should now only be accessed via cache, as ownership has been transferred.- Parameters:
key- the associated key of the blockdata- the block datasize- the size of the data
-
putAndPin
Places a new block in the cache and returns a pinned handle. Note that objects are immutable and cannot be overwritten.- Parameters:
key- the associated key of the blockdata- the block datasize- the size of the data
-
handover
-
putSourceBacked
void putSourceBacked(BlockKey key, Object data, long size, OOCIOHandler.SourceBlockDescriptor descriptor) Places a new source-backed block in the cache and registers the location with the IO handler. The entry is treated as backed by disk, so eviction does not schedule spill writes.- Parameters:
key- the associated key of the blockdata- the block datasize- the size of the datadescriptor- the source location descriptor
-
putAndPinSourceBacked
BlockEntry putAndPinSourceBacked(BlockKey key, Object data, long size, OOCIOHandler.SourceBlockDescriptor descriptor) Places a new source-backed block in the cache and returns a pinned handle.- Parameters:
key- the associated key of the blockdata- the block datasize- the size of the datadescriptor- the source location descriptor
-
addReference
Notifies the cache that there is another reference to the same block key. This will prevent forget(key) from removing the block from cache. A block will only be forgotten after all referencing instances called forget(key).- Parameters:
key-
-
forget
Forgets a block from the cache.- Parameters:
key- the associated key of the block
-
pin
Pins a BlockEntry in cache to prevent eviction.- Parameters:
entry- the entry to be pinned
-
unpin
Unpins a pinned block.- Parameters:
entry- the entry to be unpinned
-
getCacheSize
long getCacheSize()Returns the current cache size in bytes. -
getPinnedBytes
long getPinnedBytes()Returns the number of pinned bytes in the cache. -
getHardLimit
long getHardLimit()Returns the hard cache limit in bytes. -
isWithinLimits
boolean isWithinLimits()Returns if the current cache size is within its defined memory limits. -
isWithinSoftLimits
boolean isWithinSoftLimits()Returns if the current cache size is within its soft memory limits. -
shutdown
void shutdown()Shuts down the cache scheduler. -
updateLimits
void updateLimits(long evictionLimit, long hardLimit) Updates the cache limits. -
snapshot
Collection<BlockEntry> snapshot()Creates a snapshot of the cache. Should only be used for debugging or diagnoses.
-