Record Class ReadCoalescingFilter
java.lang.Object
java.lang.Record
com.loomcache.server.handler.ReadCoalescingFilter
public record ReadCoalescingFilter(DataOperationHandler handler, RequestCoalescer coalescer)
extends Record
A filter that wraps a DataOperationHandler to add read request coalescing.
Read operations (GET, CONTAINS_KEY, SIZE) are intercepted and coalesced to reduce redundant work under high concurrency. Write operations (PUT, DELETE, etc.) are passed through unchanged.
Coalescing is configurable and can be toggled on/off at runtime.
Thread-safe: Delegates to the underlying handler and RequestCoalescer, both of which are thread-safe.
- Since:
- 1.0
-
Constructor Summary
ConstructorsConstructorDescriptionReadCoalescingFilter(DataOperationHandler handler) Create a new ReadCoalescingFilter.ReadCoalescingFilter(DataOperationHandler handler, RequestCoalescer coalescer) Create a new ReadCoalescingFilter with a custom RequestCoalescer. -
Method Summary
Modifier and TypeMethodDescriptionGet the underlying RequestCoalescer.final booleanIndicates whether some other object is "equal to" this one.@Nullable MessageHandle a message, applying coalescing for read operations.handler()Get the underlying handler.final inthashCode()Returns a hash code value for this object.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
ReadCoalescingFilter
Create a new ReadCoalescingFilter.- Parameters:
handler- the underlying DataOperationHandler to wrap (non-null)- Throws:
NullPointerException- if handler is null
-
ReadCoalescingFilter
Create a new ReadCoalescingFilter with a custom RequestCoalescer.- Parameters:
handler- the underlying DataOperationHandler to wrap (non-null)coalescer- the RequestCoalescer to use (non-null)- Throws:
NullPointerException- if handler or coalescer is null
-
-
Method Details
-
handle
Handle a message, applying coalescing for read operations.If the operation is a read operation (GET, CONTAINS_KEY, SIZE) and coalescing is enabled, the request is coalesced. Otherwise, it is passed through directly.
- Parameters:
message- the incoming message (non-null)- Returns:
- the response message
- Throws:
NullPointerException- if message is null
-
coalescer
-
handler
-
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object).
-