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
Nested classes/interfaces inherited from interface io.netty.channel.ChannelHandler
io.netty.channel.ChannelHandler.Sharable
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void
decode
(io.netty.channel.ChannelHandlerContext ctx, RequestCtx requestCtx, List<Object> out) protected void
encode
(io.netty.channel.ChannelHandlerContext ctx, ResponseCtx msg, List<Object> out) protected void
onHit
(io.netty.channel.ChannelHandlerContext ctx, RequestCtx requestCtx, ResponseCtx responseCtx, List<Object> out) protected void
onMiss
(io.netty.channel.ChannelHandlerContext ctx, RequestCtx requestCtx, List<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
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.netty.channel.ChannelHandler
handlerAdded, handlerRemoved
-
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, List<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, List<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, List<Object> out) - Specified by:
decode
in classio.netty.handler.codec.MessageToMessageCodec<RequestCtx,
ResponseCtx>
-
encode
protected void encode(io.netty.channel.ChannelHandlerContext ctx, ResponseCtx msg, List<Object> out) - Specified by:
encode
in classio.netty.handler.codec.MessageToMessageCodec<RequestCtx,
ResponseCtx>
-