Package org.tinyradius.io.server.handler
Class BasicCachingHandler
java.lang.Object
io.netty.channel.ChannelHandlerAdapter
io.netty.channel.ChannelInboundHandlerAdapter
io.netty.channel.ChannelDuplexHandler
io.netty.handler.codec.MessageToMessageCodec<RequestCtx,ResponseCtx>
org.tinyradius.io.server.handler.BasicCachingHandler
- All Implemented Interfaces:
io.netty.channel.ChannelHandler
,io.netty.channel.ChannelInboundHandler
,io.netty.channel.ChannelOutboundHandler
public class BasicCachingHandler extends io.netty.handler.codec.MessageToMessageCodec<RequestCtx,ResponseCtx>
Simple caching handler backed by ConcurrentHashMap, invalidates using
Timer
.-
Nested Class Summary
-
Constructor Summary
Constructors Constructor Description BasicCachingHandler(io.netty.util.Timer timer, int ttlMs)
-
Method Summary
Modifier and Type Method Description protected void
decode(io.netty.channel.ChannelHandlerContext ctx, RequestCtx requestCtx, java.util.List<java.lang.Object> out)
protected void
encode(io.netty.channel.ChannelHandlerContext ctx, ResponseCtx msg, java.util.List<java.lang.Object> out)
protected void
onHit(io.netty.channel.ChannelHandlerContext ctx, RequestCtx requestCtx, ResponseCtx responseCtx, java.util.List<java.lang.Object> out)
protected void
onMiss(io.netty.channel.ChannelHandlerContext ctx, RequestCtx requestCtx, java.util.List<java.lang.Object> out)
Methods inherited from class io.netty.handler.codec.MessageToMessageCodec
acceptInboundMessage, acceptOutboundMessage, channelRead, write
Methods inherited from class io.netty.channel.ChannelDuplexHandler
bind, close, connect, deregister, disconnect, flush, read
Methods inherited from class io.netty.channel.ChannelInboundHandlerAdapter
channelActive, channelInactive, channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaught, userEventTriggered
Methods inherited from class io.netty.channel.ChannelHandlerAdapter
ensureNotSharable, handlerAdded, handlerRemoved, isSharable
-
Constructor Details
-
BasicCachingHandler
public BasicCachingHandler(io.netty.util.Timer timer, int ttlMs)- Parameters:
timer
- for cache evictionttlMs
- time for items to stay cached after being returned, in milliseconds
-
-
Method Details
-
onMiss
protected void onMiss(io.netty.channel.ChannelHandlerContext ctx, RequestCtx requestCtx, java.util.List<java.lang.Object> out)- Parameters:
ctx
- ChannelHandlerContextrequestCtx
- inbound request contextout
- list to which decoded messages should be added
-
onHit
protected void onHit(io.netty.channel.ChannelHandlerContext ctx, RequestCtx requestCtx, ResponseCtx responseCtx, java.util.List<java.lang.Object> out)- Parameters:
ctx
- ChannelHandlerContextrequestCtx
- inbound request contextresponseCtx
- outbound response contextout
- list to which decoded messages should be added
-
decode
protected void decode(io.netty.channel.ChannelHandlerContext ctx, RequestCtx requestCtx, java.util.List<java.lang.Object> out)- Specified by:
decode
in classio.netty.handler.codec.MessageToMessageCodec<RequestCtx,ResponseCtx>
-
encode
protected void encode(io.netty.channel.ChannelHandlerContext ctx, ResponseCtx msg, java.util.List<java.lang.Object> out)- Specified by:
encode
in classio.netty.handler.codec.MessageToMessageCodec<RequestCtx,ResponseCtx>
-