java.lang.Object
org.firebirdsql.gds.ng.wire.InlineBlobCache
- All Implemented Interfaces:
DatabaseListener,TransactionListener
@NullMarked
public final class InlineBlobCache
extends Object
implements DatabaseListener, TransactionListener
Cache for inline blobs of a single attachment.
- Since:
- 6.0.2
- Author:
- Mark Rotteveel
-
Constructor Summary
ConstructorsConstructorDescriptionInlineBlobCache(FbDatabase database) Creates an inline blob cache with themaxBlobCacheSizeconfigured fordatabase. -
Method Summary
Modifier and TypeMethodDescriptionbooleanadd(FbTransaction transaction, InlineBlob blob) Adds an inline blob to the cache for the transaction and blob id.voiddetached(FbDatabase database) Called when thedatabaseconnection has been detachedgetAndRemove(FbTransaction transaction, long blobId) Gets an inline blob for the transaction and blob id and removes it from the cache.intmaxSize()intsize()voidtransactionStateChanged(FbTransaction transaction, TransactionState newState, TransactionState previousState) Signals that the transaction state changed.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.firebirdsql.gds.ng.listeners.DatabaseListener
detaching, warningReceived
-
Constructor Details
-
InlineBlobCache
Creates an inline blob cache with themaxBlobCacheSizeconfigured fordatabase.- Parameters:
database- database instance
-
-
Method Details
-
maxSize
public int maxSize()- Returns:
- the maximum cache size,
-1if the cache is disabled
-
size
public int size()- Returns:
- the current cache size
-
getAndRemove
Gets an inline blob for the transaction and blob id and removes it from the cache.- Parameters:
transaction- transactionblobId- blob id- Returns:
- inline blob or empty if not present in the cache
- See Also:
-
getAndRemove(int, long)
-
add
Adds an inline blob to the cache for the transaction and blob id.The inline blob is not stored in the cache if:
transactionis not activeFbTransaction.getHandle()is not equal toInlineBlob.getTransactionHandle()- Adding the blob would exceed the maximum cache size
If the blob is stored, this cache is added as a transaction listener of
transaction.- Parameters:
transaction- transactionblob- inline blob- Returns:
trueif the blob was added to the cache,falseotherwise
-
transactionStateChanged
public void transactionStateChanged(FbTransaction transaction, TransactionState newState, TransactionState previousState) Description copied from interface:TransactionListenerSignals that the transaction state changed.- Specified by:
transactionStateChangedin interfaceTransactionListener- Parameters:
transaction-FbTransactionthat changed state
-
detached
Description copied from interface:DatabaseListenerCalled when thedatabaseconnection has been detached- Specified by:
detachedin interfaceDatabaseListener- Parameters:
database- The database object that was detached
-